tests: Add device test proving SKGLView renders after reattach (validates #3076)#3554
Open
mattleibow wants to merge 1 commit intomainfrom
Open
tests: Add device test proving SKGLView renders after reattach (validates #3076)#3554mattleibow wants to merge 1 commit intomainfrom
mattleibow wants to merge 1 commit intomainfrom
Conversation
fbfbfe0 to
d059c71
Compare
5 tasks
Adds SKGLViewTests.GLThreadHasCorrectDimensionsAfterReattach, an Android device test that validates the fix in PR #3076. The test exercises the exact failure mode: - Uses native Android RemoveView/AddView to detach/reattach the GL view without triggering MAUI's handler lifecycle (which would recreate the view) - Reads GLThread.width/height via reflection immediately after AddView(), before any async OnLayoutChange callback can supply dimensions WITHOUT the fix (PR #3076): GLThread starts with width=0, height=0 → FAIL ⛔ "GLThread dimensions should be positive immediately after OnAttachedToWindow, got 0x0" WITH the fix (PR #3076): GLThread starts with correct dimensions → PASS ✔ Success! ~1600ms Relates to #2550. Test validates fix in #3076. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
d059c71 to
04e413e
Compare
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
This PR adds an Android device test that proves the fix in PR #3076 works:
got 0x0The fix itself lives in #3076 (by @SimonvBez). This PR contains only the test.
Test:
GLThreadHasCorrectDimensionsAfterReattachFile:
tests/SkiaSharp.Tests.Devices/Tests/Maui/SKGLViewTests.csThe Bug (issue #2550)
When
SKGLViewis placed on a MAUITabBartab, switching away and back causes it to stop rendering. Root cause:OnAttachedToWindow()createsnew GLThread(weakRef)withwidth=0, height=0. Because the view's bounds haven't changed, Android never firesOnLayoutChangeagain — soGLThread.OnWindowResize()is never called.IsReadyToDraw()keeps returningfalse(requireswidth > 0 && height > 0), so the view never renders.How the test works
RemoveView()/AddView()to detach and reattach — bypassing MAUI's handler lifecycle (which would recreate the view)GLThread.width/heightvia reflection immediately afterAddView()— before any asyncOnLayoutChangecallback can supply dimensions> 0This captures the raw state
OnAttachedToWindow()sets, which is exactly the window where the bug lives in the real tab-bar scenario.Before/After Results (on
emulator-5554)Without fix (#3076 not applied):
With fix (#3076 applied):
Related