-
Notifications
You must be signed in to change notification settings - Fork 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
Image Web/Desktop: Add support for http headers #36560
Image Web/Desktop: Add support for http headers #36560
Conversation
@aimane-chnaif Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
@Beamanator please generate adhoc build |
Creating adhoc build soon 👍 Update: Building... https://github.com/Expensify/App/actions/runs/7913538905 |
This comment has been minimized.
This comment has been minimized.
@aimane-chnaif, @francoisl, @Beamanator I couldn't recreate the problem that led to reverting the previous PR, following these steps: #35636 (comment) Furthermore, until the receipt image is uploaded and processed we're supplying the local file blob to represent the receipt image This means the browser can release the local blob resource when it's no longer used, though I wasn't able to reproduce this either, but technically if you refresh, or better yet close the app window and open it again this local blob might be released to conserve resources I have a working theory that since it takes some time to process a receipt, once the receipt result is ready the backend provides the remote attachment address, at that point the user happened to be offline and the remote image couldn't load Or perhaps the issue @francoisl encountered is an unrelated, intermittent bug that manifests independently of the image update changes. |
Not sure if it helps, but here's what I'm seeing from https://36560.pr-testing.expensify.com/
Screen.Recording.2024-02-15.at.12.18.13.PM.mov |
I believe I've identified the issue—the preflight response isn't being cached, resulting in its repeated execution with each image render. While the images themselves are cached, the browser is forced to reinitiate the preflight check due to the absence of caching headers. These headers are crucial as they instruct the browser on whether and how long to cache the preflight request. Consequently, in offline scenarios, the browser is unable to perform the preflight request, leading to a failure in loading all images. Here are some visuals to illustrate the point: To fix the issue in offline usage, and omit doing preflight request for cached items we should add some cache to the preflight response as well (this is a backend task) |
We're holding on this PR in #35041. Is this going to land relatively soon, or should we just figure out the way forward without waiting for this? |
Conflicts ⚔️ |
This Pull Request cannot be merged at this time due to unresolved issues related to preflight caching, as detailed in this comment. Proceeding with the merge before implementing the required backend adjustments would replicate the offline experience issues that previously necessitated a revert, as seen in PR #35636. I will address any conflicts that arise in the meantime once the backend changes are completed, setting the stage for us to move forward with this PR. |
@Beamanator are you going to take this on, or perhaps @justinpersaud, as you've been helping out on resolving some backend issues related to this? |
@kidroca I just deployed a change to enable caching of preflight requests if you'd like to test again and report back. |
5911738
to
c5bf5fc
Compare
It doesn't seem possible to use the current PR review environment: https://36560.pr-testing.expensify.com/ I've pushed updates to sync with |
- Introduced `BaseImage` component that branches between native and web implementations. - **Native**: Utilizes `expo-image` directly. - **Web**: Minor adjustments made to the `onLoad` event signature for compatibility. - Eliminated `Image/index.native.js` as both native and web components now leverage a unified high-level implementation for image loading and rendering. - Added `BaseImage` specific props - Adapt to `expo-image` deprecation of `event.nativeEvent` usage. - Ensure compatibility with components using the `onLoad` prop.
c5bf5fc
to
22a1de0
Compare
@amyevans, thank you for your assistance. However, it appears that this PR was still significantly out of sync with I've just re-synced with |
Sorry y'all, I just got back from vacay 🙏 I just triggered another adhoc build 👍 - https://github.com/Expensify/App/actions/runs/8264151190 |
🧪🧪 Use the links below to test this adhoc build on Android, iOS, Desktop, and Web. Happy testing! 🧪🧪 |
Hello @Beamanator, I noticed that the Web build and deploy process was successful: https://github.com/Expensify/App/actions/runs/8264151190/job/22607147679. However, there seems to be an issue, as the review environment still displays the "Update Requested" screen. This could either be because the build isn't using the latest code, or there might be a build issue. Upon inspecting the details, I observed that App's version in the network calls is Could you investigate, or confirm you have the same issue on this review env: https://36560.pr-testing.expensify.com/ |
Same here 🤔 I'm able to sign in and I see |
Thank you for checking, everyone. It appears to have been a caching issue, as switching to a different browser resolved the problem for me. I can no longer reproduce the issue with thumbnail images when offline, nor the issue with failed receipt OCRs. I've confirmed that the preflight requests are now cached for 24 hours, which means they are entirely skipped in CORS checks. ✔️ The PR is now ready for review. It has already been reviewed and approved in previous iterations, but it's worth taking another look since I introduced some changes while resolving conflicts with the recent conversion of the Image to TypeScript. |
Amazing, thanks so much @kidroca 🙏 @aimane-chnaif can you please do another full review before we move forward with this PR? |
Hope this behavior would be fine: (at least not blocker) Offline icon glitches for a brief moment (around 21s in video) Screen.Recording.2024-03-17.at.4.24.16.PM.mov |
Reviewer Checklist
Screenshots/VideosAndroid: Nativeandroid.movAndroid: mWeb Chromemchrome.moviOS: Nativeios.moviOS: mWeb Safarimsafari.movMacOS: Chrome / Safariweb.movMacOS: Desktopdesktop.mov |
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 looks great to me, Hoping this is the last time we have to merge this 🙏
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
🚀 Deployed to staging by https://github.com/Beamanator in version: 1.4.54-0 🚀
|
🚀 Deployed to production by https://github.com/AndrewGable in version: 1.4.54-4 🚀
|
Note: This PR was previously reverted (see PR #35636 for reference). Our objective now is to identify an issue that manifests only post-deployment. We should be able to use the
pr-testing
link to detect any problems in loading/rendering imagesDetails
This PR refactors the
Image
component, aligning the web/desktop and native implementations for better consistency and maintainability.Changes:
Introduced
BaseImage
Component:src/components/Image/BaseImage.tsx
onLoad
event, it ensures that both web and native platforms have the same signature.Native Implementation Update:
src/components/Image/BaseImage.native.tsx
expo-image
, with a slight adjustment for theonLoad
prop, to make it's interface uniform.Unified Image Component for Web/Desktop and Native:
src/components/Image/index.js
Image
component has been refactored to use the newBaseImage
.Removed Redundant Native Specific Implementation:
src/components/Image/index.native.js
Patch for
react-native-web
patches/react-native-web+0.19.9+005+image-header-support.patch
Fixed Issues
$ #12603
PROPOSAL: N/A
Tests
Verify the Image component works on all platforms
X-Chat-Attachment-Token
header.X-Chat-Attachment-Token
value changes.Offline tests
QA Steps
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.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)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Design
label so the design team can review the changes.ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
Screen.Recording.2024-02-15.at.9.35.41.mov
MacOS: Desktop