fix: support defaultSource on the New Architecture (Fabric) β iOS, Android & JS#387
Open
glc-helmbarki wants to merge 1 commit into
Open
Conversation
defaultSource was ignored on the New Architecture, leaving a blank view while the remote image loads (issue dream-horizon-org#385). - iOS: the Fabric component view (updateProps:) never applied defaultSource. Convert the resolved URI to a UIImage via {uri, __packager_asset: YES} so it works in debug (Metro packager URL) and release. - JS: under Fabric, defaultSource is typed as a String natively, so resolve the asset to a URI instead of returning the raw require() number (which iOS stringified to e.g. "42", unusable). - Android: load the placeholder through Glide (thumbnail while loading, error on failure) and show it when there is no valid source, since getResourceDrawable cannot resolve a packager/remote URI. Fixes dream-horizon-org#385
There was a problem hiding this comment.
Orca Security Scan Summary
| Status | Check | Issues by priority | |
|---|---|---|---|
| Infrastructure as Code | View in Orca | ||
| SAST | View in Orca | ||
| Secrets | View in Orca | ||
| Vulnerabilities | View in Orca |
|
π Thanks for your first Pull Request! |
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.
Problem
defaultSourceis ignored when the New Architecture (Fabric) is enabled, so theview stays blank while the remote image loads. Closes #385.
Root cause is per-platform:
FFFastImageViewComponentView.updateProps:)handled
source,resizeMode, etc. but never applieddefaultSource.defaultSourceis typed as aStringnatively, butresolveDefaultSourcereturned the rawrequire()number on iOS, which wasthen
String()-ified to e.g."42"β unusable natively.setDefaultSourceonly resolves a local resource name viagetResourceDrawable; a packager/remote URI (debug) returnsnull, and noplaceholder was shown when the source was empty/invalid.
Fix
src/index.tsx): under Fabric, resolve the asset to a URI(
Image.resolveAssetSource(...).uri).FFFastImageViewComponentView.mm): applydefaultSourceinupdateProps:by converting the URI to aUIImagevia{uri, __packager_asset: YES}(works in debug and release). Builds on fix iOS support default image (new architecture).Β #355.FastImageViewWithUrl.java,FastImageViewManager.java): keep theraw URI and, when it isn't a local
Drawable, load the placeholder throughGlide β
.thumbnail()while loading,.error()on failure β and show it whenthere is no valid source.
Tested