fix(🤖): clip HorizontalScrollView in makeImageFromView snapshots#3862
Open
hirvesh wants to merge 2 commits into
Open
fix(🤖): clip HorizontalScrollView in makeImageFromView snapshots#3862hirvesh wants to merge 2 commits into
hirvesh wants to merge 2 commits into
Conversation
ViewScreenshotService clips scroll containers to their viewport while compositing the view tree, but only checks `instanceof ScrollView`. HorizontalScrollView does not extend ScrollView (both extend FrameLayout), so a horizontal scroll container was never clipped: an oversized child such as a wide Skia <Canvas> (a TextureView) inside one bled past its viewport to the output bitmap edge in the captured image. Clip HorizontalScrollView as well; getScrollX/Y/getWidth/getHeight are View methods so the existing clip math works unchanged (the ScrollView cast is dropped). iOS is unaffected.
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.
Context
makeImageFromViewon Android composites the view tree inViewScreenshotService. While descending, it clips scroll containers to their viewport so off-screen content isn't drawn:Problem
HorizontalScrollViewdoes not extendScrollView— both extendFrameLayout. So a horizontal scroll container never matches this check and is never clipped. When it contains a child larger than its viewport — e.g. a wide Skia<Canvas>, which renders into aTextureViewand is blitted at full surface size indrawTextureView— the child bleeds past the viewport all the way to the output bitmap edge in the captured image.Repro: a horizontally-scrollable Skia
<Canvas>whose content is wider than the screen, captured viamakeImageFromView. The captured image shows the canvas overrunning its container's right edge. iOS is unaffected (it captures through the live layer tree's clip).Fix
Check
HorizontalScrollViewin the same branch.getScrollX/getScrollY/getWidth/getHeightare allViewmethods, so the existing clip-rect math is unchanged (the now-unnecessaryScrollViewcast is dropped).Verified against the overflow repro on a physical Pixel 9a (new architecture): the captured Skia canvas is now correctly clipped to the horizontal
ScrollViewviewport, matching iOS.