Fix stopped lifecycle callback ordering - #6442
Open
jbdevprimary wants to merge 1 commit into
Open
Conversation
dweymouth
requested changes
Aug 6, 2026
| return a.driver | ||
| } | ||
|
|
||
| func TestRunLifecycleShutdown(t *testing.T) { |
Contributor
There was a problem hiding this comment.
This test is so complicated to read I don't even really understand what it's doing. I especially don't think a unit test should ever need an exec.Command call, just let the go test runner invoke the test. The actual code change is so small I'd be fine with reverting both test files and just shipping the one line change. The l.QueueEvent is mostly a remnant of when event callbacks ran in a separate thread pre-Fyne 2.6 anyway (you can see in the same file a bit above your change that we just directly call f() for the OnStarted callback already).
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.
Description:
Run the GLFW stopped lifecycle callback synchronously on the app/main goroutine before the function queue is drained.
The shutdown loop currently queues the composite stopped callback after Terminate and immediately drains the function queue. Depending on timing, the callback can be drained without execution and then run through the post-drain direct path from another goroutine. That breaks lifecycle ordering, moves the callback off the app goroutine, and can race cleanup.
This keeps the existing Terminate-before-OnStopped ordering, but invokes the already-composed callback directly from runGL before queue drain. The user hook still runs before the internal preferences hook. Mobile behavior is unchanged.
A fresh-subprocess regression proves both stopped hooks run exactly once, on the main goroutine, before drained is set; Driver.Run returns; and a background DoAndWait queued during shutdown is released without its canceled callback executing.
Related to #5748, but deliberately does not claim to fix the broader post-shutdown Do/DoAndWait queue race.
Local focused, race, ci/migrated_fynedo, no_glfw, WebAssembly build, lint, vet, and formatting checks pass. The full platform/GLFW matrix is left to upstream CI because the local macOS suite has an unrelated nil-monitor failure and local Linux/ARM64 golden images differ.
Checklist: