Commit a9e91f4
Fix deadlock on activity onDestroy
Fix a deadlock that occurs when an activity is destroyed without process
termination, such as when an activity is destroyed and recreated due to
a configuration change.
The deadlock occurs because `notify_destroyed` blocks until `destroyed`
is set to `true`. This only occurs when `WaitableNativeActivityState` is
dropped, but the `WaitableNativeActivityState` instance is the very
thing being used to await for destruction, resulting in a deadlock.
Instead of waiting for the `WaitableNativeActivityState` to be dropped
we now wait until the native `android_main` thread has stopped.
So we can tell the difference between the thread not running because it
hasn't started or because it has finished (in case `android_main`
returns immediately) this replaces the `running` boolean with a
tri-state enum.
Co-authored-by: Robert Bragg <robert@sixbynine.org>1 parent 0f00a58 commit a9e91f4
1 file changed
Lines changed: 32 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
199 | 199 | | |
200 | 200 | | |
201 | 201 | | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
202 | 214 | | |
203 | 215 | | |
204 | 216 | | |
| |||
210 | 222 | | |
211 | 223 | | |
212 | 224 | | |
213 | | - | |
| 225 | + | |
214 | 226 | | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
215 | 230 | | |
216 | 231 | | |
217 | 232 | | |
| |||
303 | 318 | | |
304 | 319 | | |
305 | 320 | | |
306 | | - | |
307 | | - | |
308 | 321 | | |
309 | 322 | | |
310 | 323 | | |
| |||
356 | 369 | | |
357 | 370 | | |
358 | 371 | | |
359 | | - | |
| 372 | + | |
360 | 373 | | |
361 | 374 | | |
362 | 375 | | |
| |||
369 | 382 | | |
370 | 383 | | |
371 | 384 | | |
| 385 | + | |
372 | 386 | | |
373 | 387 | | |
374 | 388 | | |
375 | | - | |
| 389 | + | |
376 | 390 | | |
377 | 391 | | |
378 | 392 | | |
| |||
541 | 555 | | |
542 | 556 | | |
543 | 557 | | |
544 | | - | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
545 | 565 | | |
546 | 566 | | |
547 | 567 | | |
| |||
907 | 927 | | |
908 | 928 | | |
909 | 929 | | |
| 930 | + | |
| 931 | + | |
910 | 932 | | |
911 | 933 | | |
912 | 934 | | |
913 | 935 | | |
914 | | - | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
915 | 940 | | |
916 | 941 | | |
917 | 942 | | |
| |||
0 commit comments