-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
[Image][Performance] Fast Image with Auth Token Header Caching (revert follow-up) #13304
[Image][Performance] Fast Image with Auth Token Header Caching (revert follow-up) #13304
Conversation
I've just done a quick test with the fix that was mentioned here in slack. It does indeed load the images and the Test image: https://user-images.githubusercontent.com/31568400/205428950-cd7119fb-cc70-4e76-9518-8027ead43f6f.jpg I will do some more digging and see if a better fix can be found as we definitely cannot apply this directly if it is going to cause crashes. Also maybe raises a question if we want to ever impose a max resolution for images and videos uploaded as chat attachments cc @Beamanator. Will keep you posted 🙌 |
Looks like Glide (the image loading module used in Fast Image on Android) requires a valid, non-zero view size before it can begin image loading as this comment from one of the collaborators suggests:
With that in mind do we still want to class the I think the options are from here:
Let me know your thoughts @Beamanator @kidroca 🙌 |
Hey @thomas-coldwell thanks so much for the in depth investigation!! I believe I'd prefer we go with options 1 or 2 ^ since they're fixing bugs instead of implementing workarounds... It looks like https://github.com/bumptech/glide/ is a pretty active repo so maybe we could get the fix in there, though that issue you linked was opened (and closed) a long time ago 😅 Maybe you can see if there's other related issues that are more recent / still open? And if not, maybe we can start a discussion there to see if it's something they'd consider "fixing"? |
Cheers @Beamanator, I agree it would be preferable to fix this at the source. I'm OOO till tomorrow, but will see what can be done with Glide or if there is any more recent issues around this 🙌 |
There doesn't seem to be any more recent issues / PRs on Glide for loading without a valid view (the source code does a check to make sure the the view's dimensions are all non-zero before loading starts). There appears to be a way to set a custom view target with glide and get it to report the natural dimensions for the image irrespective of the view it is being laid out into. This will likely then become a PR into the |
Actually, this seems to be the recommended way of getting the natural dimensions of the image with Glide and ensure that it is only making a single request or decoding this from the cached image bumptech/glide#781 (comment). One question I have is do we want to always report the natural image dimensions in the
I'm assuming we do want the natural dimensions so the API is identical with RN core image component? I'm conscious that the image displayed by glide will not actually have these dimensions but I don't think this will have any knock on effects as the width and height are just used to compute image aspect ratio and not directly for other view layouts. |
@thomas-coldwell since there's no current issues / PRs on Glide about this issue, do you think it makes sense to open an issue there to discuss this situation? It's possible those maintainers would recommend we take this issue to the Also I am not sure who we'd contact at About the natural image dimensions vs resized dimensions, this is getting a bit far above my understanding, sorry 😅 So far I like your thinking but honestly I don't quite understand the benefits / drawbacks very well - if you think you're onto something I thinkkkk we should move forward with that and see what library maintainers think and move forward that way? Also FYI I'm going to start a discussion in Slack (soon) to see if people think we should move forward with a little workaround while this conversation / implementation is happening in other repos, then once the fix is implemented & is usable by the New Expensify app, we can remove the workaround. Coming soon :D |
Hey @Beamanator 👋 I don't think it makes sense to open an issue with Glide, glide works as it should loading an image into a target - usually a drawable. This is how Glide is used in Fast Image. The fix that I've found, and implemented in a separate sandbox app, is to setup an additional request for glide which decodes the image to get the size and then emits this as the I agree there seems to be literally no difference between the fork we are currently using and the main The natural dimensions are that of the source image we load from the backend e.g. you might have a 1000x1000px image. With Glide and a lot of other image loading libraries they will resize this down appropriately for the target e.g. if its being loaded into a tiny 50x50dp view (like a profile picture) then it will resize it down to maybe 100x100px to preserve memory. I think it makes more sense to do it the same as the RN core Image API and report the natural dimensions so will stick with that 👍 |
That sounnnds great! Do you think we should try to test it with our App before moving forward with that solution? Or was your test solid enough? :D About the forking question - we reeeeally try not to make our own Forks whenever possible, so what we'll most likely do is try to get the conversation & PR going on the main |
Perfect, cheers @Beamanator !! I'll create a fork and apply my changes there, open up a PR to the OG repo and then I'll test using my PR branch in the Expensify app as well to make sure there are no obvious issues with this approach 🙌 |
That sounds fantastic, thanks so much @thomas-coldwell ! 👍 |
I've fixed any merge conflicts there were (as I'm now creating a PR for I will link this here when it's up 🙂 |
Thanks @thomas-coldwell ! I think I'll wait till some resolution on this convo (feel free to add your opinion) before testing w/ my workaround PR :D |
Opened up the PR on the |
Reached out to maintainer to see if we can get the upstream PR moving - if no response this week we will have to think about forking |
Established with @puneetlath that a patch of the upstream PR will work best for now and works perfectly fine with the native code changes. The upstream PR will remain open and hopefully the maintainer will have some time to eventually look at it - if it does get merged upstream this patch can then be removed and upgraded to the latest version |
0a17bfa
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.
Great @thomas-coldwell and @kidroca I think we are now all happy and this can be merged as we had 5 approvals before.
Is there anything else @kidroca which you would like to address?
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.
Thanks for the quick response & fix @thomas-coldwell 👍
I think we should do one more round of testing before we merge 🙏
Yeah I agree. I am going to test this in a while @Beamanator. Give me like 30-45 mins. |
Amazing, thanks so much @mananjadhav 👍 |
Amazing @mananjadhav |
@thomas-coldwell , @Beamanator Quick update, I just tested Desktop and Web. The caching seems to be working fine. I won't be able to do offline tests as I can't disconnect my laptop from Wifi right now. While I am testing other platforms, I found one issue. I missed to check this earlier. When I download the images and PDF, the file name of the downloaded file is correct. But when I download a word document, the file name of the downloaded doc, doesn't match the original file name. This works fine with staging and production. Attaching the video. web-file-download-name.mov |
@thomas-coldwell @Beamanator So I did all the testing for all the platforms and the caching works fine. I've got two concerns/issues:
android-offline-loader.mov |
Thanks for the tests and notes @mananjadhav ! In my opinion:
|
Okay for 1. for 2, what I meant is opening the image for the first time in the offline mode. I am inclined to solve this also as a follow up Pr because the behavior is same as prod, but just wanted to highlight it here. |
Thanks @mananjadhav and @Beamanator I've just checked out |
@mananjadhav Aah because the image hasn't been viewed yet so it probably hasn't been cached either? I'd at least expect a consistent thing to happen across apps - but yeah as @thomas-coldwell said if this is consistent with production, let's discuss outside this PR - probably in Slack to get some more eyes 👍 |
Thanks for confirming @thomas-coldwell. Agreed to keep both of them outside the scope of this PR. All good here then. |
FYI it looks like the failing test is not related to this PR, and it was noted in Slack here: https://expensify.slack.com/archives/C01GTK53T8Q/p1673916481148719 So I'm going to merge 👍 |
@Beamanator looks like this was merged without a test passing. Please add a note explaining why this was done and remove the |
Performance Comparison Report 📊Significant Changes To DurationThere are no entries Meaningless Changes To DurationShow entries
Show details
|
🚀 Deployed to staging by @Beamanator in version: 1.2.56-0 🚀
|
🚀 Deployed to production by https://github.com/AndrewGable in version: 1.2.56-0 🚀
|
Details
This PR is the follow up the the original fast image PR that was reverted here. The key improvements in this PR are:
Image
component itself (+ reactive with thewithOnyx
HoC rather thanOnyx.connect()
)react-native-fast-image
would not load if the style width / height were set to zero.Fixed Issues
Original image caching issue - #10792
Android PDF thumbnail not displayed (triggered initial revert) - #13002
Tests
npm i
Offline tests
NOTE: The thumbnail images should be cached for any attachment type, however, when opening the attachment view for an attachment only image attachments will be cached - for example, PDFs will have their preview thumbnail image cached, but the PDF file itself is not cached and thus it is expected behaviour that you will see "Failed to load PDF" when performing steps 3&4 for PDF attachment.
QA Steps
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)src/languages/*
files and using the translation methodWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)/** comment above it */
this
properly so there are no scoping issues (i.e. foronClick={this.submit}
the methodthis.submit
should be bound tothis
in the constructor)this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)ScrollView
component to make it scrollable when more elements are added to the page.Screenshots/Videos
Web
Mobile Web - Chrome
Mobile Web - Safari
Desktop
Screen.Recording.2023-01-03.at.14.58.27.mov
iOS
Simulator.Screen.Recording.-.iPhone.14.Pro.Max.-.2023-01-03.at.14.28.23.mp4
Android
Screen.Recording.2023-01-03.at.14.45.23.mov