diff --git a/runtime/gfx_window_win.c b/runtime/gfx_window_win.c index 155ebf31..6f9cb5be 100644 --- a/runtime/gfx_window_win.c +++ b/runtime/gfx_window_win.c @@ -589,6 +589,10 @@ static LRESULT CALLBACK wnd_proc(HWND h, UINT m, WPARAM w, LPARAM l) { } case WM_ACTIVATEAPP: { int in = w != 0; + // The end's own hide (exit_start, which sets g_exit_started first on this thread) deactivates the window: no + // player's focus loss. Taken as one, the present thread's next present wrote the session's report for the whole + // run and started a new period (perf.c perf_focus_lost), so "frametime: exit" covered only the frames since. + if (!in && __atomic_load_n(&g_exit_started, __ATOMIC_ACQUIRE)) return 0; gfx_window_focus_changed(in); if (in && g_fs_pending) { g_fs_pending = 0; diff --git a/tests/exit_order_check.py b/tests/exit_order_check.py index 32bee6a3..23506614 100644 --- a/tests/exit_order_check.py +++ b/tests/exit_order_check.py @@ -172,6 +172,16 @@ def static_checks(): print(f'gfx_window_win.c: WM_CLOSE and WM_ENDSESSION start the end on its own thread and hide the window: ' f'{"ok" if ok else "FAIL"}', flush=True) bad += not ok + # the hide's focus loss is the end's, not a player's: it must not reach perf.c perf_focus_lost, whose session report + # would take the exit summary's frames + act = proc[proc.index('case WM_ACTIVATEAPP:'):proc.index('case WM_ENDSESSION:')] + start = function(win, 'static PlatThread *exit_start(') + guard, focus = act.find('g_exit_started'), act.find('gfx_window_focus_changed(') + ok = (0 <= guard < focus and 'return 0;' in act[guard:focus] and '!in' in act[:focus] + and 0 <= start.find('g_exit_started') < start.find('ShowWindow(h, SW_HIDE)')) + print(f'gfx_window_win.c: a focus loss once the end has begun (the hide) does not reach gfx_window_focus_changed: ' + f'{"ok" if ok else "FAIL"}', flush=True) + bad += not ok steps = function(gp, 'void rt_exit_steps(unsigned what)') pos = calls_in_order(steps, ['rtss_limit_restore', 'vk_pipeline_save_exit']) ok = None not in pos and pos[0] < pos[1]