-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RNMobile] Update Image component to avoid flicker when updating the URI #57869
[RNMobile] Update Image component to avoid flicker when updating the URI #57869
Conversation
Size Change: +1.42 kB (0%) Total Size: 1.7 MB
ℹ️ View Unchanged
|
… behavior between platforms
Flaky tests detected in 5c4d2d7. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/7707646158
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This turned out to be a complex subject. 😅 From my initial testing, the functionality works as described. Well done! 👏🏻
I did notice that replacing media for an Image or Gallery block does not show the newly selected local image immediately. Instead, it displays the previous image until the upload completes, it then swaps to the new image instantly. I'm not sure if this an existing issue or not.
I also noticed an image can flash when the upload finishes in a Gallery block, but only on occasion. It occurs sometimes when I upload ~4 images to a new Gallery block. It could be unrelated to the Gallery block and I just happen to recreate it more frequently with Gallery block given it generally houses multiple images.
Resolves layout display issue when block is selected
@dcalhoun Good catch, I also noted that the newly selected local image does not immediately replace the local file until it's uploaded to the server. While it still prevents the flickering, I think it's worth seeing if we can improve the replace behavior as well. |
The mobile image component introduce new asynchronous effects. We must await the result of those effect, in the form of asserting UI changes from the subsequent state updates, to satisfy the React test utilities expectation that unexpected re-renders do not occur after the test completes. Additionally, there were instances of awaiting `act` invocations that were not asynchronous. The erroneous usage of `await` for these synchronous `act` calls resulted in cryptic errors. In reality, the logic run within these `act` calls are synchronous and should merely be wrapped in `act` to signal that they result in a re-render.
Using width: 1 and height: 1 ensures that onLoad will fire
…://github.com/wordpress/gutenberg into rnmobile/prevent-image-flicker-when-uploading
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not note any new regressions in my testing. During my testing I noted:
- [Known Regression] Replacing an image does not display the new image until the upload is completed, which is a regression that we may choose to ship. I left an inline comment regarding a potential solution.
- On iOS only, Media + Text and Cover blocks do not display the local image during the upload, but this appears to be true in the production app as well.
- Choosing a photo from a "free photo library" does not result in a smooth transition.
Co-authored-by: David Calhoun <github@davidcalhoun.me>
…://github.com/wordpress/gutenberg into rnmobile/prevent-image-flicker-when-uploading
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The proposed changes look good to me.
I have not retested with the latest commits after #57869 (review), as there is not an updated prototype build. However, if you'd like for me to re-test something, please let me know.
I will also note that we should re-test for any Android regressions you noted in #57869 (comment).
Thank you for improving this image upload experience!
On iOS, add 1 to height to account for the 1px non-visible image that is used to determine when the network image has loaded We also must verify that it is not NaN, as it can be NaN when the image is loading.
I ran through the regression tests for both platforms, and did not note any with the updated logic. Your logic change also improved the replacement behavior for Android -- thanks for the contribution! I did note that when an image is selected on iOS, there is a 1px offset between the border and the image due to the non-visible image. I noted this as something to fix in a previous comment, and updated the |
@dcalhoun I have started the main apps build CI jobs to reference the latest changes, and tested both platforms successfully locally. Although you've already approved, I just wanted to provide a final chance for any review from the last change to update the selected image styles, and general testing using the prototype builds (which should have succeeded by the time you read this). Tomorrow I intend to test the main apps CI builds and if successful, merge the Gutenberg / Gutenberg Mobile PRs before cutting the 1.112.0 release. Thanks for your feedback and contributions to this fix. 🙇 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Latest changes look good and tested well for me on iOS and Android. Hopefully we can refactor/remove this complexity in the future. Thanks for seeing this improvement through!
What?
Fixes an issue where image uploads disappear or "blink" when transitioning from local to network states.
Related PRs:
Why?
Fixes:
Currently when uploading an Image, the Image itself "blinks" when transitioning its URI reference from a local on-device image to the uploaded, network-available image. This "blink" is possibly due to the time spent downloading the network-available resource itself, where the visual asset appears unavailable while the network image is downloading.
How?
Adds more descriptive states when a
uri
is changed to await the full loading of a network-based image, before swapping out the URI from the local filestore-based image.Testing Instructions
Screenshots or screencast