Commit 3acf7c6
Ubuntu
fix: tick native watchdog before SetFormat to prevent black screen
When the surface is born as RGB565 on Vulkan, the RGB565 guard in
SurfaceChanged calls SetFormat(RGBA8888) which triggers a synchronous
surface teardown on the UI thread. This blocks the UI thread for hundreds
of milliseconds, preventing the Update thread from sending heartbeats to
the native watchdog. The native watchdog (10s default) then fires, killing
the process and producing a black screen.
The fix calls NativeWatchdog.Heartbeat() right before SetFormat to reset
the watchdog timer from the UI thread. The native watchdog checks
g_lastHeartbeatMonotonicSec which is updated by a simple atomic store
— safe to call from any thread and never throws.
This is safer than the previous approach of setting surfaceEvent before
SetFormat, which introduced a data race between the draw thread reading
surfaceGlobalRef and SurfaceDestroyed freeing it.1 parent 90dc644 commit 3acf7c6
1 file changed
Lines changed: 19 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
| |||
899 | 900 | | |
900 | 901 | | |
901 | 902 | | |
902 | | - | |
903 | | - | |
904 | | - | |
905 | | - | |
906 | | - | |
907 | | - | |
908 | | - | |
909 | | - | |
910 | | - | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
911 | 920 | | |
912 | | - | |
913 | | - | |
| 921 | + | |
914 | 922 | | |
915 | 923 | | |
916 | 924 | | |
| |||
0 commit comments