Fix image disappearing on Nougat with antialiased border radius clipping#55527
Open
Abbondanzo wants to merge 1 commit intofacebook:mainfrom
Open
Fix image disappearing on Nougat with antialiased border radius clipping#55527Abbondanzo wants to merge 1 commit intofacebook:mainfrom
Abbondanzo wants to merge 1 commit intofacebook:mainfrom
Conversation
Summary: On API 24 (Nougat), the `DST_OUT` + `EVEN_ODD` inverse path technique in `clipWithAntiAliasing()` doesn't render correctly — it erases all image content instead of just the area outside the rounded rect. The bug manifests specifically with ReactImageView (Fresco-backed) but not plain ImageView. ReactImageView's Fresco hierarchy configures `RoundingParams.RoundingMethod.BITMAP_ONLY`, which causes the drawable chain to draw through a `BitmapShader`-based paint. This shader-based drawing interacts badly with the `EVEN_ODD` fill + `DST_OUT` compositing inside a hardware-accelerated `saveLayer` on API 24's Skia renderer. The fix replaces the `EVEN_ODD` + `DST_OUT` technique with a nested `saveLayer` using `DST_IN` compositing, following the same pattern used by Facebook's Keyframes library (`AbstractLayer.applyClip`). The mask shape is drawn into a separate layer; when restored with `DST_IN`, content is preserved only where the mask is opaque. A `drawColor(CLEAR)` call after `saveLayer` ensures the layer starts fully transparent — without this, on API 24, the layer may retain parent content, causing `DST_IN` to see non-zero alpha everywhere and clip nothing. Changelog: [Android][Fixed] - Fix image content disappearing on API 24 (Nougat) when antialiased border radius clipping is applied Differential Revision: D92980234
|
@Abbondanzo has exported this pull request. If you are a Meta employee, you can view the originating Diff in D92980234. |
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:
On API 24 (Nougat), the
DST_OUT+EVEN_ODDinverse path technique inclipWithAntiAliasing()doesn't render correctly — it erases all image content instead of just the area outside the rounded rect.The bug manifests specifically with ReactImageView (Fresco-backed) but not plain ImageView. ReactImageView's Fresco hierarchy configures
RoundingParams.RoundingMethod.BITMAP_ONLY, which causes the drawable chain to draw through aBitmapShader-based paint. This shader-based drawing interacts badly with theEVEN_ODDfill +DST_OUTcompositing inside a hardware-acceleratedsaveLayeron API 24's Skia renderer.The fix replaces the
EVEN_ODD+DST_OUTtechnique with a nestedsaveLayerusingDST_INcompositing, following the same pattern used by Facebook's Keyframes library (AbstractLayer.applyClip). The mask shape is drawn into a separate layer; when restored withDST_IN, content is preserved only where the mask is opaque. AdrawColor(CLEAR)call aftersaveLayerensures the layer starts fully transparent — without this, on API 24, the layer may retain parent content, causingDST_INto see non-zero alpha everywhere and clip nothing.Changelog: [Android][Fixed] - Fix image content disappearing on API 24 (Nougat) when antialiased border radius clipping is applied
Differential Revision: D92980234