Repository navigation
waylandbridge: destroy frame callbacks on dispatch thread - #91
Merged
superturtlee merged 1 commit intoSep 28, 2026
Merged
Conversation
Keep delivered frame callbacks parked after sending done from the render thread, then destroy them when the client dispatch thread requests its next callback. This avoids racing libwayland object-map mutation against callback ID allocation.
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.
Summary
Destroy delivered
wl_callbackresources on the client dispatch thread instead of therender thread.
This avoids a race between
wl_resource_destroy()mutating the client’s Wayland objectmap and the dispatch thread creating the next frame callback with a newly reusable
object ID.
Problem
awl_surface_presented()runs on the render thread. It previously performed all threeoperations there:
wl_callback.done.Meanwhile, the client dispatch thread can process another
wl_surface.framerequestand create a new callback. Destroying the old resource concurrently with that
allocation can corrupt or confuse the client object map.
During physical drag-and-drop testing, this produced a protocol error such as:
Change
The render thread now:
wl_callback.done.On the client’s next
wl_surface.framerequest,surface_frame()destroys deliveredcallbacks before creating the replacement callback. This keeps object-map mutation on
the dispatch thread.
Callbacks are also reclaimed during normal surface teardown if the client does not
request another frame.
Why the deferred destruction is safe
The callback remains alive briefly after done is sent, so its object ID cannot be
reused until the server destroys it and emits delete_id.
Destroying delivered callbacks before creating the next callback keeps the parked set
bounded under the normal frame-request cycle.
The existing recursive per-surface ev_lock allows the resource-destruction listener to
remove the callback from the list while surface_frame() performs this cleanup.
Testing
main.wl_callbackprotocol error.The runtime build also contained the separate DnD event-ordering fix; this PR contains
only the frame-callback lifecycle change.
Scope
This does not move
wl_callback.donedelivery back to the dispatch thread. Cross-threadevent sending remains handled by Anland’s patched libwayland synchronization.
The change only moves
wl_resource_destroy()and the associated object-map mutation tothe client dispatch thread.