Skip to content

webgl: Unconditionally decrement busy count of WebGL contexts.#41094

Merged
mukilan merged 1 commit intoservo:mainfrom
mukilan:fix-webgl-crash
Dec 6, 2025
Merged

webgl: Unconditionally decrement busy count of WebGL contexts.#41094
mukilan merged 1 commit intoservo:mainfrom
mukilan:fix-webgl-crash

Conversation

@mukilan
Copy link
Copy Markdown
Member

@mukilan mukilan commented Dec 6, 2025

The current logic returns early without decrementing the busy count if the swap chain doesn't have a front surface. This happens if the context was created but never used for rendering, as seen in the linked issue. Since the count is always incremented when locking, this causes the count to never reach zero, causing the cleanup logic in remove_webgl_context to skip freeing the context and associated resources.

Fixes #41082.

Testing: A new crash test is added.

@mukilan mukilan requested a review from mrobinson as a code owner December 6, 2025 06:26
@servo-highfive servo-highfive added the S-awaiting-review There is new code that needs to be reviewed. label Dec 6, 2025
@servo-wpt-sync
Copy link
Copy Markdown
Collaborator

🤖 Opened new upstream WPT pull request (web-platform-tests/wpt#56545) with upstreamable changes.

@servo-wpt-sync
Copy link
Copy Markdown
Collaborator

✍ Updated existing upstream WPT pull request (web-platform-tests/wpt#56545) title and body.

@servo-highfive servo-highfive removed the S-awaiting-review There is new code that needs to be reviewed. label Dec 6, 2025
The current logic returns early without decrementing the busy count if
there are the swap chain doesn't have a front surface. This happens if
the context was created but never used for rendering, as seen in the
linked issue. Since the count is always incremented when locking, this
causes the count to never reach zero, causing the cleanup logic in
`remove_webgl_context` to skip freeing the context and associated
resources.

Fixes servo#41082.

Signed-off-by: Mukilan Thiyagarajan <[email protected]>
@servo-highfive servo-highfive added the S-awaiting-review There is new code that needs to be reviewed. label Dec 6, 2025
@mukilan mukilan enabled auto-merge December 6, 2025 07:58
@servo-wpt-sync
Copy link
Copy Markdown
Collaborator

📝 Transplanted new upstreamable changes to existing upstream WPT pull request (web-platform-tests/wpt#56545).

@mukilan mukilan added this pull request to the merge queue Dec 6, 2025
@servo-highfive servo-highfive added the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Dec 6, 2025
Merged via the queue into servo:main with commit e531770 Dec 6, 2025
32 checks passed
@mukilan mukilan deleted the fix-webgl-crash branch December 6, 2025 09:01
@servo-highfive servo-highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Dec 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-awaiting-review There is new code that needs to be reviewed.

Projects

None yet

4 participants