Fix UI freeze: clamp FPSLimit frame-limiter underflow in draw_screen()#99
Open
szb78 wants to merge 1 commit into
Open
Fix UI freeze: clamp FPSLimit frame-limiter underflow in draw_screen()#99szb78 wants to merge 1 commit into
szb78 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix Uint32 underflow in manual FPS limiter causing permanent UI freeze
Fixes #98
Problem
When
VSync=falseand anFPSLimitis set, the manual frame limiter indraw_screen()(src/launcher.c) computes the sleep time as an unsignedsubtraction:
Whenever a frame overruns its target interval — which happens on any blocking
texture load, e.g. returning from a launched application, navigating menus, or a
submenu transition —
(SDL_GetTicks() - ticks.main)exceedsrefresh_period.The
Uint32subtraction then underflows to a huge value (~4.29e9), soSDL_Delay()sleeps for ~49 days and the UI freezes permanently. Because theprocess is alive but hung, a watchdog/restart loop can't recover it — it needs a
power cycle.
Fix
Compare before subtracting, so the delay is only computed (and applied) when the
frame finished early:
When a frame overruns, we simply skip the delay and proceed to the next frame.
Testing
Built from this branch and deployed on an HP T640 (Ubuntu 24.04, SDL 2.30).
Reproduced the freeze reliably on the original binary with
VSync=false+FPSLimit=15by launching an app and returning to the menu; the patched binaryruns through the same flow — startup, submenu in/out, and app launch-and-return —
with no freeze.
With the FPS limiter now working safely, idle resource usage on the static menu
also dropped sharply: