expo / expo

An open-source framework for making universal native apps with React. Expo runs on Android, iOS, and the web.
https://docs.expo.dev
MIT License
34.9k stars 5.6k forks source link

Super slow file upload on iOS in background mode using expo-file-system #26754

Open rajsawhoney opened 10 months ago

rajsawhoney commented 10 months ago

Minimal reproducible example

Here's the git repo with minimal reproducible example: https://github.com/rajsawhoney/expo-minimal-example

const handleUpload = () => {
    const task = FileSystem.createUploadTask(
      "<s3-pre-signed-url>",
      media?.uri as string,
      {
        sessionType: FileSystem.FileSystemSessionType.BACKGROUND,
        uploadType: FileSystem.FileSystemUploadType.BINARY_CONTENT,
        headers: {
          "Content-Type": "video/mp4",
        },
      },
      (result) => {
        const { totalBytesSent, totalBytesExpectedToSend } = result;
        console.log(
          "UploadTask Progress:",
          `${((totalBytesSent / totalBytesExpectedToSend) * 100).toFixed(0)}%`
        );
      }
    );
    task
      .uploadAsync()
      .then((res) => {
        if (res != null && res?.status >= 200 && res?.status < 300) {
          console.log("File Uploaded!", res);
        } else {
          console.log("Failed to upload!", res);
        }
      })
      .catch((err: Error) => {
        console.log("Failed to upload!", err);
      });
  };

Summary

Expected Behavior: It should upload file on iOS in background mode at normal speed(based on internet bandwidth).

Current Behavior: The upload speed is super slow on iOS in background mode, however it uploads with quite better speed(normal) in foreground mode and so does on android(both mode)

Environment

expo-env-info 1.2.0 environment info: System: OS: macOS 14.2.1 Shell: 5.9 - /bin/zsh Binaries: Node: 18.18.0 - /usr/local/bin/node Yarn: 1.22.19 - /usr/local/bin/yarn npm: 9.2.0 - ~/node_modules/.bin/npm Managers: CocoaPods: 1.12.1 - /opt/homebrew/bin/pod SDKs: iOS SDK: Platforms: DriverKit 23.2, iOS 17.2, macOS 14.2, tvOS 17.2, visionOS 1.0, watchOS 10.2 Android SDK: API Levels: 33 Build Tools: 30.0.3, 33.0.0, 33.0.1, 34.0.0 System Images: android-33 | Google APIs ARM 64 v8a IDEs: Android Studio: 2021.3 AI-213.7172.25.2113.9123335 Xcode: 15.2/15C500b - /usr/bin/xcodebuild npmPackages: expo: ^50.0.4 => 50.0.4 expo-router: ^3.4.6 => 3.4.6 react: 18.2.0 => 18.2.0 react-dom: 18.2.0 => 18.2.0 react-native: 0.73.2 => 0.73.2 react-native-web: ~0.19.6 => 0.19.10 npmGlobalPackages: eas-cli: 7.0.0 expo-cli: 6.3.10 Expo Workflow: managed

muhzain commented 9 months ago

Is there any update on this? File upload is very slow on IOS(foreground, background or any other mode) while it works fine on android. Can we please get a solution for this asap? This is a blocker for my application

v-anton commented 8 months ago

I have exactly same issue. The upload is only slow using expo-file-system

muhzain commented 8 months ago

Do we have any update on this? This is the only blocker for me.

raid5 commented 7 months ago

Following this thread as well, we are actively investigating slow iOS image uploads.

Hannes1 commented 6 months ago

Same problem, when set to BACKGROUND it's super slow

      let result = await FileSystem.createUploadTask(
        url,
        uri,
        {
          sessionType: FileSystem.FileSystemSessionType.BACKGROUND,
          httpMethod: "POST",
          fieldName: "file",
          uploadType: FileSystem.FileSystemUploadType.MULTIPART,
        },
        callback
      ).uploadAsync();
github-actions[bot] commented 3 months ago

This issue is stale because it has been open for 90 days with no activity. If there is no activity in the next 7 days, the issue will be closed.

rajsawhoney commented 3 months ago

Hey bot we're still waiting for its fixes...

coofzilla commented 3 months ago

any update? same issue.

ddematheu commented 3 months ago

Any update?

smspasha commented 4 days ago

Any update?