Skip to content

Fix ANR/crash in AndroidGraphics.destroy() due to infinite wait()#7699

Merged
obigu merged 2 commits into
libgdx:masterfrom
palatin:fix-androidgraphics-destroy-wait-hang
Nov 27, 2025
Merged

Fix ANR/crash in AndroidGraphics.destroy() due to infinite wait()#7699
obigu merged 2 commits into
libgdx:masterfrom
palatin:fix-androidgraphics-destroy-wait-hang

Conversation

@palatin
Copy link
Copy Markdown
Contributor

@palatin palatin commented Sep 7, 2025

Summary

This PR resolves an ANR/crash in AndroidGraphics.destroy() (#7626) caused by an infinite wait() when onDrawFrame() is never invoked

Technical Details

  • The fix follows the same approach already used in the pause() method: it manually enqueues a call to onDrawFrame.
  • This ensures that destroy() can complete without blocking indefinitely.
  • It applies the same logic introduced in PR #6745, but that PR was closed without being merged.

@bitdream
Copy link
Copy Markdown

bitdream commented Nov 26, 2025

When will it be merged? I can see this bug in my console log too.

Copy link
Copy Markdown
Member

@tommyettinger tommyettinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently I reviewed these changes in an earlier PR and approved them. That PR couldn't be merged, so the review went away, but I'll still approve this one... even though I really don't do much Android stuff at all, and don't know if this will work or if it is still needed.

@bitdream
Copy link
Copy Markdown

Apparently I reviewed these changes in an earlier PR and approved them. That PR couldn't be merged, so the review went away, but I'll still approve this one... even though I really don't do much Android stuff at all, and don't know if this will work or if it is still needed.

Does aprroved mean it will be merged into the master brach so we can get the update?
I see the info showed is "can be merged" not "has been merged" so it has not been merged yet.

Copy link
Copy Markdown
Contributor

@obigu obigu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue seems to only affect AndroidFragment based apps and the fix has been confirmed to work. Should be harmless for non Fragment apps.

@obigu obigu merged commit 0d669f0 into libgdx:master Nov 27, 2025
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ANR/Crash on Android due to infinite wait() in AndroidGraphics.destroy()

4 participants