Skip to content

[Due for payment 2026-11-11] [$175] Attachments - Image flashes briefly after uploading #103619

Closed

Description

@applause-bot

If you haven’t already, check out our contributing guidelines for onboarding. To join our Slack channel, fill out this form.


Version Number: 9.5.6-0
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from BrowserStack: #102852
Email or phone of affected tester (no customers): emady.syed123+sign@gmail.com
Issue reported by: Applause Internal Team
Bug source: Pull Request QA execution
Device used: realme c21y / android 11
App Component: Chat Report View

Action Performed:

Precondition: Have an image larger than 24 MiB in size and less than 50 megapixels in resolution.

Steps:

  1. Navigate to a DM.
  2. Click + > Add attachment.
  3. Select the image and upload it.

Expected Result:

Image should not flash after uploading

Actual Result:

Image flashes briefly after uploading.

Workaround:

Unknown

Platforms:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome Safari

Screenshots/Videos

Bug7282061_1791540463219.XRecorder_20261009_03.mp4

View all open jobs on GitHub

Applause Internal Information
Exported by: Svetlana Lazutkina
Bug ID: 7282061

Upwork Automation - Do Not Edit
Issue OwnerCurrent Issue Owner: @mallenexpensify

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Oct 9, 2026
  2. MelvinBot commented on Oct 9, 2026

    @MelvinBot
    Contributor

    Proposal

    This looks like a duplicate of [$175] Image thumbnail flickers after sending an attachment on iOS and Android. That issue has an open fix in Key native attachment thumbnails on the attachment ID so they stay on screen after send. The 24 MiB size is not the cause. Small images flash the same way.

    What is the root cause of that problem?

    On native, the thumbnail's image view uses the image URI as its recyclingKey (BaseImage.native.tsx:55). expo-image clears the view each time that key changes. After you send an attachment, its URI changes twice:

    1. From the local picked file to the cached copy (useCachedAttachmentSource.ts:98-102).
    2. From the cached copy to the remote URL, when the server response replaces the optimistic HTML.

    Each change blanks the image until the new source loads, so you see a flash.

    Why images over 24 MiB look worse

    Large images go through resizeImageIfNeeded. The URI sequence stays the same, so there is no extra swap. But the native branch of createFile returns only uri, name, and type (FileUtils.ts:676-683). It drops the width and height from the resize step. The optimistic HTML then has no size attributes (ReportUtils.ts:7440-7458). So the thumbnail starts at the 200x200 default (ThumbnailImage.tsx:77-78) and jumps to its real size when it loads. That jump can make the flash more visible.

    Endless spinner when uploading image, the PR under QA here, changed only the web branch of createFile. It did not cause this iOS bug.

    What changes do you think we should make in order to solve the problem?

    1. Close this as a duplicate and fix it through the existing issue. Its PR keys the native thumbnail on the attachment ID, not the URI, so both swaps keep the image on screen. That covers images over 24 MiB too.
    2. Optional follow-up: have the native branch of createFile keep width, height, and size. This removes the 200x200-to-real-size jump for resized images.

    What alternative solutions did you explore? (Optional)

    None. The existing PR targets the same mechanism.

    Open question and related issues
    • Open question: the attachment-ID fix only works if the server's AddAttachment HTML keeps the client's data-attachment-id. If it doesn't, the key still changes at the remote swap. The PR author reports no flash on iOS and Android, which suggests the ID is kept.
    • Not reproduced here: this bug is iOS native only, and this run could test only on web.
    • Related: [iOS] All attachments reload after successfully sending an attachment.

    Next Steps for Contributor+ team:
    To accept: @MelvinBot implement [this](https://github.com/Expensify/App/issues/103619) to create a draft PR.
    To refine: @MelvinBot <your feedback>
    To reject: Explain why you are rejecting Melvin's proposal.


    view run

  3. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Oct 9, 2026
  4. melvin-bot commented on Oct 9, 2026

    @melvin-bot

    Triggered auto assignment to Contributor-plus team member for initial proposal review - @marufsharifi (External)

  5. changed the title [-]Attachments - Image flashes briefly after uploading[/-] [+][$175] Attachments - Image flashes briefly after uploading[/+] on Oct 9, 2026
  6. melvin-bot commented on Oct 9, 2026

    @melvin-bot
  7. yuvrajangadsingh commented on Oct 9, 2026

    @yuvrajangadsingh
    Contributor

    withdrawing this, it went up before the issue had the Help Wanted label. will come back if the label is added.

  8. khizzcr7 commented on Oct 9, 2026

    @khizzcr7

    Proposal

    Root cause: After the upload completes, the attachment preview swaps its image source (local thumbnail/placeholder to the remote URL), and the swap remounts or reloads the image, causing a visible flash.
    Fix approach: Keep a stable image key across the transition and keep showing the local thumbnail until the remote image's onLoad fires, then swap without unmounting.
    Verification: Upload an image larger than 24 MiB and confirm no flash appears in the attachment preview.

  9. janiya2 commented on Oct 9, 2026

    @janiya2

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    When uploading an image larger than 24 MiB (and under 50 MP) on iOS/Android, the optimistic thumbnail in the chat message flashes and abruptly snaps its aspect ratio a moment after appearing, unlike images under 24 MiB which render smoothly.

    What is the root cause of that problem?

    For images exceeding CONST.API_ATTACHMENT_VALIDATIONS.MAX_SIZE (24 MiB), the app executes resizeImageIfNeeded via useFilesValidation.
    Inside resizeImageIfNeeded:
    https://github.com/Expensify/App/blob/main/src/libs/fileDownload/FileUtils.ts#L697-L700
    getImageManipulator resizes the image and returns a FileObject containing uri, width, and height:
    https://github.com/Expensify/App/blob/main/src/libs/fileDownload/getImageManipulator/index.native.ts#L7-L14

    However, resizeImageIfNeeded then passes this result through createFile(file). In createFile:
    https://github.com/Expensify/App/blob/main/src/libs/fileDownload/FileUtils.ts#L676-L683

    const createFile = (file: File): FileObject => {
        if (getPlatform() === CONST.PLATFORM.ANDROID || getPlatform() === CONST.PLATFORM.IOS) {
            return {
                uri: file.uri,
                name: file.name,
                type: file.type,
            };
        }

    On native platforms, createFile rebuilds the object strictly with uri, name, and type, dropping width and height.

    Consequently, when getUploadingAttachmentHtml generates the optimistic HTML tag:
    https://github.com/Expensify/App/blob/main/src/libs/ReportUtils.ts#L7451-L7452
    the attributes data-expensify-width and data-expensify-height are omitted ('width' in file is false). ThumbnailImage then falls back to default 200x200 dimensions. Once expo-image asynchronously finishes measuring the local file on disk, setImageDimensions abruptly updates the container width and aspect ratio, causing the visible flash/snap.

    What changes do you think we should make in order to solve the problem?

    1. Update createFile in src/libs/fileDownload/FileUtils.ts to preserve width and height:

    https://github.com/Expensify/App/blob/main/src/libs/fileDownload/FileUtils.ts#L676-L691

    import type {Dimensions} from '@src/types/utils/Layout';
    
    const createFile = (file: File & Partial<Dimensions>): FileObject => {
        if (getPlatform() === CONST.PLATFORM.ANDROID || getPlatform() === CONST.PLATFORM.IOS) {
            return {
                uri: file.uri,
                name: file.name,
                type: file.type,
                width: file.width,
                height: file.height,
            };
        }
        const clonedFile = new File([file], file.name, {
            type: file.type,
            lastModified: file.lastModified,
        });
        // `uri` is a custom property that the File constructor doesn't copy, and attachment previews need it
        clonedFile.uri = file.uri;
        if (file.width !== undefined) {
            clonedFile.width = file.width;
        }
        if (file.height !== undefined) {
            clonedFile.height = file.height;
        }
        return clonedFile;
    };

    This guarantees that resized native attachments retain their scaled dimensions just like picked images, allowing getUploadingAttachmentHtml to stamp the thumbnail size attributes from the very first frame.

    What alternative solutions did you explore? (Optional)

    1. Re-measuring via ImageSize.getSize in ReportUtils: This adds unnecessary async overhead before dispatching optimistic actions and duplicates work already performed by getImageDimensionsAfterResize.
    2. Hiding ThumbnailImage until onLoad: This leads to jarring blank placeholders instead of smooth optimistic thumbnails. Preserving dimensions at source in createFile mirrors the standard unresized attachment flow and provides optimal UX.

    Unit / Regression Tests

    1. Unit Tests in tests/unit/FileUtilsTest.ts:
      • Update createFile native test to assert that width and height are preserved on the cloned object:
        expect(clonedFile).toEqual({uri: 'file://image.jpeg', name: 'image.jpeg', type: 'image/jpeg', width: 1920, height: 1080});
      • Add a test for resizeImageIfNeeded on native verifying that the returned FileObject contains the dimensions returned by the mocked getImageManipulator.
    2. Manual QA:
      • On iOS / Android, navigate to a DM.
      • Tap + > Add attachment.
      • Select an image > 24 MiB (under 50 MP) and tap Send.
      • Verify the optimistic thumbnail displays immediately with its correct aspect ratio without snapping or flashing.
  10. janiya2 commented on Oct 9, 2026

    @janiya2

    Contributor details:

  11. camesenin commented on Oct 13, 2026

    @camesenin
  12. melvin-bot commented on Oct 13, 2026

    @melvin-bot

    ✅ Contributor details stored successfully. Thank you for contributing to Expensify!

  13. 28 remaining items

  14. melvin-bot commented on Nov 8, 2026

    @melvin-bot

    📣 @jeff-graham-ai! 📣
    Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork.
    Please follow these steps:

    1. Make sure you've read and understood the contributing guidelines.
    2. Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
    3. Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
    4. Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details.
      Screen Shot 2022-11-16 at 4 42 54 PM
      Format:
    Contributor details
    Your Expensify account email: <REPLACE EMAIL HERE>
    Upwork Profile Link: <REPLACE LINK HERE>
    
  15. marufsharifi commented on Nov 9, 2026

    @marufsharifi

    Contributor+ Checklist:

    • [Contributor] The offending PR and associated issue have been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.

      Link to the comment on the PR:
      Link to the comment on the Issue:

    • [Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.

      Link to discussion:

    • [Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.

    Regression Test Proposal

    Precondition:

    • Have a JPEG image larger than 24 MiB and smaller than 50 megapixels.

    Android: Native / iOS: Native

    Test:

    1. Launch the app and sign in.
    2. Open a DM conversation.
    3. Tap + → Add attachment.
    4. Select the image larger than 24 MiB.
    5. Send the image.
    6. Verify the image thumbnail appears with the correct aspect ratio immediately.

    Do we agree 👍 or 👎

  16. added
    Awaiting PaymentAuto-added when associated PR is deployed to production
    and removed on Nov 9, 2026
  17. melvin-bot commented on Nov 10, 2026

    @melvin-bot

    Triggered auto assignment to @mallenexpensify (Awaiting Payment)

  18. melvin-bot commented on Nov 10, 2026

    @melvin-bot

    Payment Summary

    Resolving PRs:

    Upwork Job

    • Assignee: @marufsharifi requires payment (Needs manual offer from BZ)

    BugZero Checklist (@mallenexpensify)

    • I have confirmed assignees, roles, and Upwork contracts look correct
    • I have paid out Upwork contracts / manual NewDot requests
    • [BugZero Assignee] I have created a GH issue for creating/updating the regression test once above steps have been agreed upon
  19. mallenexpensify commented on Nov 16, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor+: @marufsharifi due $175 via Upwork

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

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions