expo icon indicating copy to clipboard operation
expo copied to clipboard

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

Open rajsawhoney opened this issue 1 year ago • 9 comments

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

rajsawhoney avatar Jan 28 '24 16:01 rajsawhoney

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

muhzain avatar Feb 22 '24 13:02 muhzain

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

v-anton avatar Mar 10 '24 15:03 v-anton

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

muhzain avatar Mar 13 '24 08:03 muhzain

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

raid5 avatar May 01 '24 18:05 raid5

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();

Hannes1 avatar May 02 '24 18:05 Hannes1

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.

github-actions[bot] avatar Jul 31 '24 19:07 github-actions[bot]

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

rajsawhoney avatar Aug 01 '24 02:08 rajsawhoney