Skip to content

Improve image uploading experience 2/2 #84964

Closed

Description

@Julesssss

Problem

After uploading an image, the app switches from the local file URI to the remote URL. This causes a visible flash — a white thumbnail with a loading spinner appears briefly even though the local and remote images are identical content.

Phase 1 (#65321) stores uploaded attachments locally via libs/actions/Attachment and libs/CacheAPI, but nothing currently uses that cache to serve the image source during or after upload. A hook is needed that checks the local cache first and returns the cached URI when available, preventing the re-fetch flash and enabling offline preview of previously uploaded images.

Open Questions

Solution

???

Linked Issues

Issue OwnerCurrent Issue Owner: @NJ-2020

Activity

  1. self-assigned this
    on Mar 11, 2026
  2. changed the title [-]Create hook for displaying local attachment source (image upload phase 2)[/-] [+]Improve image uploading experience 2/2[/+] on Mar 11, 2026
  3. Julesssss commented on Mar 11, 2026

    @Julesssss
    ContributorAuthor

    @NJ-2020 we can use this as a fresh issue for phase 2, please go ahead and update the description with further relevant plans. Or lets discuss!

  4. added
    Improvement
    Weekly
    on Mar 11, 2026
  5. NJ-2020 commented on Mar 12, 2026

    @NJ-2020
    Contributor

    Open Questions

    • Cache quota/eviction:
      • Not sure how to handle this — if some attachments fail to cache due to a Quota exceeded error, it could cause inconsistency between remote and local image sources (some cached, some not).
      • For remote attachments, we could show a ⚠️ Warning like This attachment couldn't be cached due to insufficient quota. For uploads, we could block new attachments from being added.
      • We could also build a storage/cache management solution, but that might be worth revisiting later.
    • Redundant caching: This should be addressed in the second PR — by preferring local sources over remote ones which will prevent expo-image from redundantly caching local files.
    • Platform scope: Maybe we can split into useCachedImageSource/index.ts for Web and useCachedImageSource/index.native.ts for Native to handle each platform separately?
  6. NJ-2020 commented on Mar 13, 2026

    @NJ-2020
    Contributor

    Question (NAB): This PR retrieves the cached source directly inside Image/BaseImage.tsx, which might cause a brief flash on slower devices — since we're still fetching the local source from CacheAPI during rendering. Is that expected?

    Maybe pre-fetching cached attachments on app/report load — and then use it later when rendering the report action item image, wdyt?

    cc: @VickyStash

  7. NJ-2020 commented on Mar 15, 2026

    @NJ-2020
    Contributor

    My plan for the second PR is to add pre-fetching for cached attachments when the app/report loads, ensuring they're ready by render time. Then we'll pass the cached source into PureReportActionItem via AttachmentContext and use it during rendering.

    Also, I'd love to hear your thoughts on this — thanks!

    cc: @Julesssss

  8. NJ-2020 commented on Mar 17, 2026

    @NJ-2020
    Contributor

    Update: I am still working on the second PR

  9. Julesssss commented on Mar 17, 2026

    @Julesssss
    ContributorAuthor

    Cache quota/eviction
    ⚠️ Warning like This attachment couldn't be cached due to insufficient quota

    At what point do you think this would be a problem? I imagine this is more of a problem on web?

    Redundant caching: This should be addressed in the second PR — by preferring local sources over remote ones which will prevent expo-image from redundantly caching local files.

    Yeah I'm not too worried about this yet. Redundancy fix could be a 3rd step IMO.

    Platform scope: Maybe we can split into useCachedImageSource/index.ts for Web and useCachedImageSource/index.native.ts for Native to handle each platform separately?

    Makes sense at a high level, though it would be good to look further into the seperate implementations.

  10. VickyStash commented on Mar 20, 2026

    @VickyStash
    Contributor

    Question (NAB): This #84409 retrieves the cached source directly inside Image/BaseImage.tsx, which might cause a brief flash on slower devices — since we're still fetching the local source from CacheAPI during rendering. Is that expected?

    Maybe pre-fetching cached attachments on app/report load — and then use it later when rendering the report action item image, wdyt?

    I was thinking about that, but the only doubt I had was the memory usage if we pre-fetch everything from cache at once.

  11. parasharrajat commented on Mar 28, 2026

    @parasharrajat
    Member

    How are we looking here @NJ-2020?

  12. 22 remaining items

  13. added
    Reviewing
    Weekly
    and removed on Aug 13, 2026
  14. melvin-bot commented on Sep 7, 2026

    @melvin-bot

    This issue has not been updated in over 15 days. @Julesssss, @parasharrajat, @NJ-2020 eroding to Monthly issue.

    P.S. Is everyone reading this sure this is really a near-term priority? Be brave: if you disagree, go ahead and close it out. If someone disagrees, they'll reopen it, and if they don't: one less thing to do!

  15. Julesssss commented on Sep 9, 2026

    @Julesssss
    ContributorAuthor

    Thank you! Sure.

    Hi @NJ-2020, how can we unblock this?

  16. added
    Weekly
    and removed on Sep 9, 2026
  17. parasharrajat commented on Sep 9, 2026

    @parasharrajat
    Member

    @Julesssss please reassign this. I am not available now to review this. Thanks.

  18. NJ-2020 commented on Sep 10, 2026

    @NJ-2020
    Contributor

    I am working on it, and I'll make sure I'll speed it up.

  19. Julesssss commented on Sep 11, 2026

    @Julesssss
    ContributorAuthor

    @Julesssss please reassign this. I am not available now to review this. Thanks.

    Thanks for your help up to this point @parasharrajat

  20. Julesssss commented on Sep 22, 2026

    @Julesssss
    ContributorAuthor

    Okay on review I think we should close this issue and related PR.

    The caching bug seems to have been fixed with #96531 and the remaining flickering issue is small enough to be resolved seperately. Thanks for the work here all.

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

Metadata

Metadata

Labels

EngineeringImprovementNot a priorityReviewingWeekly

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions