Skip to content

Avoid Image ofscreen render#45948

Closed
NickGerleman wants to merge 3 commits into
facebook:mainfrom
NickGerleman:export-D60972846
Closed

Avoid Image ofscreen render#45948
NickGerleman wants to merge 3 commits into
facebook:mainfrom
NickGerleman:export-D60972846

Conversation

@NickGerleman
Copy link
Copy Markdown
Contributor

Summary:
This change effectively reverts D59489788 which fixed Image implementation of hasOverlappingRendering(). When this is true, Android will draw offscreen, then composite the rasterized layer with alpha in one pass, instead of drawing each element with alpha (which results in incorrect rendering).

The unforseen downside is that this prevents drawing overflow, which means images with non-full opacity break box shadows and outline in the future.

This deserves a fuller fix... but in the meantime, I discovered we disable offscreen alpha in many of the core components already, with <View> as a major example requiring explicit opt-in. This is... kinda terrible, since opacity rendering is pretty broken on RN Android, but the status quo lets us avoid a pretty bad boxShadow bug for now.

Changelog:
[Android][Changed] - Avoid image ofscreen render

Differential Revision: D60972846

NickGerleman and others added 3 commits August 8, 2024 10:05
…#45805)

Summary:
Pull Request resolved: facebook#45805

After recent changes where we dive into paths ourselves, we really don't have a good reason to use the heavy CSSBackgroundDrawable. Accept a box shadow style in place of a reference to the original drawable, and then draw using calculated round rect path instead of new whole Drawable. This lets us avoid a lot of conversions as well (with the last diff already removing some).

This should also resolve a crash we started seeing:

```
androidx.core.util.Preconditions.checkNotNull (Preconditions.java:136) [inlined]
- com.facebook.react.uimanager.drawable.CSSBackgroundDrawable.drawRoundedBackgroundWithBorders (CSSBackgroundDrawable.java:386)
 [inlined]
- com.facebook.react.uimanager.drawable.CSSBackgroundDrawable.draw (CSSBackgroundDrawable.java:142)
- com.facebook.react.uimanager.drawable.OutsetBoxShadowDrawable.draw (OutsetBoxShadowDrawable.kt:137)
- android.graphics.drawable.LayerDrawable.draw (LayerDrawable.java:1019)

```

Changelog: [Internal]

Differential Revision: D60401423
Summary:
This adjusts logic to be similar to InsetBoxShadowDrawable to keep the full ink within RenderNode bounds. This avoids a tiny bit of overdraw, but also means we get correct rendering if RenderNode is promoted to a compositing layer.

Changelog: [Internal]

Differential Revision: D60972085
Summary:
This change effectively reverts D59489788 which fixed Image implementation of `hasOverlappingRendering()`. When this is true, Android will draw offscreen, then composite the rasterized layer with alpha in one pass, instead of drawing each element with alpha (which results in incorrect rendering).

The unforseen downside is that this prevents drawing overflow, which means images with non-full opacity break box shadows and outline in the future.

This deserves a fuller fix... but in the meantime, I discovered we disable offscreen alpha in many of the core components already, with `<View>` as a major example requiring explicit opt-in. This is... kinda terrible, since `opacity` rendering is pretty broken on RN Android, but the status quo lets us avoid a pretty bad boxShadow bug for now.

Changelog:
[Android][Changed] - Avoid image ofscreen render

Differential Revision: D60972846
@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. p: Facebook Partner: Facebook Partner labels Aug 8, 2024
@facebook-github-bot
Copy link
Copy Markdown
Contributor

This pull request was exported from Phabricator. Differential Revision: D60972846

@facebook-github-bot
Copy link
Copy Markdown
Contributor

This pull request has been merged in 620b122.

@react-native-bot
Copy link
Copy Markdown
Collaborator

This pull request was successfully merged by @NickGerleman in 620b122

When will my fix make it into a release? | How to file a pick request?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported Merged This PR has been merged. p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants