amplify-js icon indicating copy to clipboard operation
amplify-js copied to clipboard

Expo / React-Native [Android-Only]: `uploadData` function calculating `onProgress` incorrectly.

Open ChristopherGabba opened this issue 7 months ago • 8 comments

Before opening, please confirm:

JavaScript Framework

React Native

Amplify APIs

Storage

Amplify Version

v6

Amplify Categories

storage

Backend

Amplify Gen 2

Environment information


  System:
    OS: macOS 15.5
    CPU: (10) arm64 Apple M2 Pro
    Memory: 571.27 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 23.4.0 - ~/.nvm/versions/node/v23.4.0/bin/node
    Yarn: 1.22.22 - /opt/homebrew/bin/yarn
    npm: 11.3.0 - ~/.nvm/versions/node/v23.4.0/bin/npm
    bun: 1.2.10 - /opt/homebrew/bin/bun
    Watchman: 2025.04.14.00 - /opt/homebrew/bin/watchman
  Browsers:
    Chrome: 137.0.7151.69
    Safari: 18.5
  npmPackages:
    %name%:  0.1.0 
    @aws-amplify/backend: ^1.11.0 => 1.16.1 
    @aws-amplify/backend-cli: ^1.7.0 => 1.7.2 
    @aws-amplify/react-native: ^1.1.6 => 1.1.10 
    @aws-amplify/rtn-web-browser: ^1.1.3 => 1.1.4 
    @aws-appsync/utils: ^2.0.3 => 2.0.3 
    @aws-sdk/client-cognito-identity-provider: ^3.799.0 => 3.826.0 
    @aws-sdk/client-dynamodb: ^3.799.0 => 3.826.0 
    @aws-sdk/client-sso-oidc: ^3.799.0 => 3.825.0 (3.622.0, 3.637.0, 3.624.0, 3.621.0)
    @aws-sdk/client-sts: ^3.799.0 => 3.825.0 (3.622.0, 3.777.0, 3.624.0, 3.621.0)
    @aws-sdk/types: ^3.775.0 => 3.821.0 (3.609.0, 3.387.0, 3.398.0, 3.775.0)
    @aws-sdk/util-dynamodb: ^3.799.0 => 3.825.0 
    @babel/core: ^7.20.0 => 7.27.4 
    @babel/plugin-proposal-export-namespace-from: ^7.18.9 => 7.18.9 
    @babel/plugin-proposal-optional-chaining: ^7.0.0 => 7.21.0 
    @babel/plugin-transform-arrow-functions: ^7.0.0 => 7.27.1 
    @babel/plugin-transform-nullish-coalescing-operator: ^7.0.0 => 7.27.1 
    @babel/plugin-transform-shorthand-properties: ^7.0.0 => 7.27.1 
    @babel/plugin-transform-template-literals: ^7.0.0 => 7.27.1 
    @babel/preset-env: ^7.20.0 => 7.27.2 
    @babel/runtime: ^7.20.0 => 7.27.6 
    @config-plugins/ffmpeg-kit-react-native: ^9.0.0 => 9.0.0 
    @expo-google-fonts/m-plus-1p: ^0.2.3 => 0.2.3 
    @expo-google-fonts/montserrat: ^0.2.3 => 0.2.3 
    @expo/config-plugins: ~10.0.0 => 10.0.2 
    @expo/metro-runtime: ~5.0.4 => 5.0.4 
    @gorhom/bottom-sheet: ^5.0.1 => 5.1.6 
    @legendapp/list: ^1.0.13 => 1.0.15 
    @react-native-async-storage/async-storage: 2.1.2 => 2.1.2 (1.24.0)
    @react-native-community/netinfo: 11.4.1 => 11.4.1 
    @react-native-menu/menu: ^1.1.0 => 1.2.3 
    @react-navigation/bottom-tabs: ^7.2.1 => 7.3.14 
    @react-navigation/native: ^7.0.15 => 7.1.10 
    @react-navigation/native-stack: ^7.2.1 => 7.3.14 
    @sentry/react-native: ~6.14.0 => 6.14.0 
    @types/i18n-js: 3.8.2 => 3.8.2 
    @types/jest: ^29.2.1 => 29.5.14 
    @types/lodash.filter: ^4.6.9 => 4.6.9 
    @types/node: ^22.10.5 => 22.15.30 
    @types/react: ~19.0.10 => 19.0.14 (18.3.23)
    @types/react-test-renderer: ^18.0.0 => 18.3.1 
    @typescript-eslint/eslint-plugin: ^8.31.1 => 8.33.1 
    @typescript-eslint/parser: ^8.31.1 => 8.33.1 
    @typescript-eslint/utils: ^8.31.1 => 8.33.1 
    ContextAPIMixpanel:  0.0.1 
    MixpanelDemo:  0.0.1 
    MixpanelExample:  0.0.1 
    SimpleMixpanel:  0.0.1 
    aws-amplify: ^6.14.4 => 6.15.0 
    aws-amplify/adapter-core:  undefined ()
    aws-amplify/adapter-core/internals:  undefined ()
    aws-amplify/analytics:  undefined ()
    aws-amplify/analytics/kinesis:  undefined ()
    aws-amplify/analytics/kinesis-firehose:  undefined ()
    aws-amplify/analytics/personalize:  undefined ()
    aws-amplify/analytics/pinpoint:  undefined ()
    aws-amplify/api:  undefined ()
    aws-amplify/api/internals:  undefined ()
    aws-amplify/api/server:  undefined ()
    aws-amplify/auth:  undefined ()
    aws-amplify/auth/cognito:  undefined ()
    aws-amplify/auth/cognito/server:  undefined ()
    aws-amplify/auth/enable-oauth-listener:  undefined ()
    aws-amplify/auth/server:  undefined ()
    aws-amplify/data:  undefined ()
    aws-amplify/data/server:  undefined ()
    aws-amplify/datastore:  undefined ()
    aws-amplify/in-app-messaging:  undefined ()
    aws-amplify/in-app-messaging/pinpoint:  undefined ()
    aws-amplify/push-notifications:  undefined ()
    aws-amplify/push-notifications/pinpoint:  undefined ()
    aws-amplify/storage:  undefined ()
    aws-amplify/storage/s3:  undefined ()
    aws-amplify/storage/s3/server:  undefined ()
    aws-amplify/storage/server:  undefined ()
    aws-amplify/utils:  undefined ()
    aws-cdk: ^2.1013.0 => 2.1018.0 
    aws-cdk-lib: ^2.194.0 => 2.200.1 
    babel-jest: ^29.2.1 => 29.7.0 
    buffer: ^6.0.3 => 6.0.3 (4.9.2, 5.6.0, 5.7.1)
    constructs: ^10.3.0 => 10.4.2 
    date-fns: ^4.1.0 => 4.1.0 
    esbuild: ^0.21.1 => 0.21.5 (0.25.5)
    eslint: ^9.26.0 => 9.28.0 
    eslint-config-prettier: 9.1.0 => 9.1.0 
    eslint-config-standard: 17.0.0 => 17.0.0 
    eslint-plugin-import: 2.26.0 => 2.26.0 
    eslint-plugin-n: ^15.0.0 => 15.7.0 
    eslint-plugin-promise: 6.6.0 => 6.6.0 
    eslint-plugin-react: ^7.37.5 => 7.37.5 
    eslint-plugin-react-native: 4.0.0 => 4.0.0 
    expo: 53.0.10 => 53.0.10 
    expo-application: ~6.1.4 => 6.1.4 
    expo-blur: ~14.1.4 => 14.1.5 
    expo-build-properties: ~0.14.6 => 0.14.6 
    expo-clipboard: ~7.1.4 => 7.1.4 
    expo-constants: ~17.1.6 => 17.1.6 
    expo-contacts: ~14.2.4 => 14.2.5 
    expo-dev-client: ~5.2.0 => 5.2.0 
    expo-device: ~7.1.4 => 7.1.4 
    expo-file-system: ~18.1.10 => 18.1.10 
    expo-font: ~13.3.1 => 13.3.1 
    expo-haptics: ~14.1.4 => 14.1.4 
    expo-image: ^2.1.7 => 2.2.0 
    expo-image-picker: ~16.1.4 => 16.1.4 
    expo-keep-awake: ~14.1.4 => 14.1.4 
    expo-linear-gradient: ~14.1.4 => 14.1.5 
    expo-linking: ~7.1.5 => 7.1.5 
    expo-localization: ~16.1.5 => 16.1.5 
    expo-secure-store: ~14.2.3 => 14.2.3 
    expo-share-intent: ^4.0.0 => 4.1.0 
    expo-sharing: ~13.1.5 => 13.1.5 
    expo-splash-screen: ~0.30.8 => 0.30.9 
    expo-status-bar: ~2.2.3 => 2.2.3 
    expo-store-review: ~8.1.5 => 8.1.5 
    expo-updates: ~0.28.13 => 0.28.14 
    expo-video: ~2.2.0 => 2.2.0 
    expo-video-metadata: ^1.5.0 => 1.5.0 
    expo-video-thumbnails: ~9.1.3 => 9.1.3 
    ffmpeg-kit-react-native: ^6.0.2 => 6.0.2 
    follow-redirects: ^1.15.9 => 1.15.9 
    i18next: ^24.2.2 => 24.2.3 
    intl-pluralrules: ^2.0.1 => 2.0.1 
    jest: ^29.2.1 => 29.7.0 
    jest-expo: ~53.0.7 => 53.0.7 
    libphonenumber-js: ^1.11.19 => 1.12.9 (1.9.47)
    libphonenumber-js-core:  undefined (1.0.0)
    libphonenumber-js-max:  undefined (1.0.0)
    libphonenumber-js-min:  undefined (1.0.0)
    libphonenumber-js-mobile:  undefined (1.0.0)
    libphonenumber-js/build:  undefined ()
    libphonenumber-js/core:  undefined ()
    libphonenumber-js/max:  undefined ()
    libphonenumber-js/max/metadata:  undefined ()
    libphonenumber-js/min:  undefined ()
    libphonenumber-js/min/metadata:  undefined ()
    libphonenumber-js/mobile:  undefined ()
    libphonenumber-js/mobile/examples:  undefined ()
    libphonenumber-js/mobile/metadata:  undefined ()
    lodash: ^4.17.21 => 4.17.21 
    lottie-react-native: 7.2.2 => 7.2.2 
    mixpanel-react-native: ^3.0.8 => 3.1.2 
    mixpanelexpo:  1.0.0 
    mobx: 6.13.5 => 6.13.5 
    mobx-react-lite: 4.0.5 => 4.0.5 
    mobx-state-tree: 7.0.1 => 7.0.1 
    onesignal-expo-plugin: ^2.0.3 => 2.0.3 
    patch-package: 6.4.7 => 6.4.7 
    postinstall-prepare: 1.0.1 => 1.0.1 
    prettier: 2.8.8 => 2.8.8 (2.3.2, 3.5.3, 1.19.1)
    react: 19.0.0 => 19.0.0 
    react-dom: 19.0.0 => 19.0.0 
    react-i18next: ^15.4.1 => 15.5.2 
    react-native: 0.79.3 => 0.79.3 
    react-native-blurhash: ^2.0.2 => 2.1.1 
    react-native-boost: ^0.5.3 => 0.5.6 
    react-native-compressor: ^1.10.5 => 1.11.0 
    react-native-gesture-handler: ~2.24.0 => 2.24.0 
    react-native-get-random-values: ^1.11.0 => 1.11.0 
    react-native-ios-context-menu: ^3.1.2 => 3.1.2 
    react-native-ios-utilities: ^5.1.5 => 5.1.5 
    react-native-mime-types: ^2.5.0 => 2.5.0 
    react-native-mmkv: ^2.12.2 => 2.12.2 
    react-native-nitro-audio-manager: ^0.1.0 => 0.1.0 
    react-native-nitro-modules: ^0.25.2 => 0.25.2 
    react-native-onesignal: ^5.2.5 => 5.2.12 
    react-native-reanimated: ~3.17.4 => 3.17.5 
    react-native-safe-area-context: 5.4.0 => 5.4.0 
    react-native-screens: 4.11.1 => 4.11.1 
    react-native-static-safe-area-insets: ^2.2.0 => 2.2.0 
    react-native-url-polyfill: ^2.0.0 => 2.0.0 
    react-native-vision-camera: ^4.6.3 => 4.6.4 
    react-native-vision-camera-face-detector: ^1.8.3 => 1.8.3 
    react-native-webview: 13.13.5 => 13.13.5 
    react-native-worklets-core: ^1.5.0 => 1.5.0 
    react-native-youtube-iframe: ^2.3.0 => 2.3.0 
    react-native-z-view: ^0.2.4 => 0.2.4 
    react-test-renderer: 18.2.0 => 18.2.0 (19.0.0)
    ts-jest: ^29.1.1 => 29.3.4 
    ts-node: ^10.9.2 => 10.9.2 
    tsx: ^4.9.4 => 4.19.4 
    typescript: ~5.8.3 => 5.8.3 (4.4.4, 4.9.5)
    uuid: ^11.0.5 => 11.1.0 (9.0.1, 3.3.2, 7.0.3)
    zeego: ^3.0.6 => 3.0.6 
    zustand: ^5.0.5 => 5.0.5 
  npmGlobalPackages:
    corepack: 0.30.0
    eas-cli: 16.3.1
    expo-cli: 6.3.12
    license-checker: 25.0.1
    npm: 11.3.0



Describe the bug

Here is my code:

await uploadToS3({
        filePath: "... path to file",
        path: `public/test.mp4`,
        options: {
          contentType: "video/mp4",
          onProgress: ({ transferredBytes, totalBytes }) => {
            if (totalBytes) {
              const uploadPercent = transferredBytes / totalBytes
              console.log(uploadPercent)
            }
          },
        },
      })
 LOG  0.0000014299216831894117
 LOG  0.5672699506248042
 LOG  1.1547318253379262
 LOG  1.7596373146642759

Its clearly calculating larger than 1.000. Note that this is only on Android. I think it has to do with the totalBytes calculation being off?

Expected behavior

Should be a maximum of 1.

Reproduction steps

See code above.

Environment (latest and greatest): react-native: 79.3 expo 53.0.10

Expo development build. If need be, I can work to get a reproduction, not sure if you guys have one already. Extremely simple code.

Code Snippet

See above.

Log output

N/A.

aws-exports.js

No response

Manual configuration

Too large to send. Let me know if needed.

Additional configuration

No response

Mobile Device

Pixel 5

Mobile Operating System

Android 14

Mobile Browser

No response

Mobile Browser Version

No response

Additional information and screenshots

No response

ChristopherGabba avatar Jun 06 '25 19:06 ChristopherGabba

Hi @ChristopherGabba thanks for opening this issue. Are you able to quickly compare totalBytes of the same file in two different applications?

nadetastic avatar Jun 06 '25 19:06 nadetastic

Now that I'm logging on iPhone I'm seeing that there is no totalBytes being fired on iOS at all. Seems like this is a known issue that was posted a while back, says its closed but I'm still getting no logs so I'm not sure.

https://github.com/expo/expo/issues/28269

So in short, this problem may be present on iOS too. I cannot get the size on both to compare, at least not during the upload. Seems like iOS isn't reporting it at all.

ChristopherGabba avatar Jun 06 '25 20:06 ChristopherGabba

Okay thanks for confirming @ChristopherGabba, I'll looking into this shortly - is this also happening on simulated devices or physical only?

nadetastic avatar Jun 06 '25 21:06 nadetastic

@nadetastic I would assume both. For sure physical devices, but it can be reproduced in iOS simulator for sure

ChristopherGabba avatar Jun 06 '25 21:06 ChristopherGabba

Hi @ChristopherGabba, we have been able to reproduce this issue on Android. I haven't been able to verify that there is also an issue with totalBytes not being fired on iOS. We’ll provide an update as soon as we have more information.

soberm avatar Jun 11 '25 14:06 soberm

Fantastic, thank you @soberm. Strange issue that I never noticed before. Maybe it was a change in the more recent future. Let me know if you need me to try anything else.

ChristopherGabba avatar Jun 11 '25 14:06 ChristopherGabba

@soberm Any update on this? Just checking in. Still just seems to be a problem on Android.

ChristopherGabba avatar Aug 07 '25 19:08 ChristopherGabba

Hello @ChristopherGabba, we are actively working on this and will let you know once we have any updates.

ahmedhamouda78 avatar Aug 08 '25 15:08 ahmedhamouda78