Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Pick a video at very first time. AssetEntity file getter return a file instance but the file size keep changing #452

Closed
JimmyTai opened this issue Mar 15, 2021 · 4 comments

Comments

@JimmyTai
Copy link

AssetEntity file getter return a file but the size keep changing.

To Reproduce
Steps to reproduce the behavior:

  1. Take a video by device camera.
  2. Get the file from AssetEntity.
  3. Get file length in a loop
  4. See file length keep changing.

Expected behavior
AssetEntity file getter should return a file after any changes.

Flutter version
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 1.22.6, on macOS 11.2.3 20D91 darwin-x64, locale
zh-Hant-TW)

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 12.4)
[✓] Android Studio (version 4.1)
[✓] VS Code (version 1.54.2)
[✓] Connected device (1 available)
! Error: Chao-Ting’s iPhone is busy: Copying cache files from device. Xcode
will continue when Chao-Ting’s iPhone is finished. (code -10)

• No issues found!

Smartphone (please complete the following information):

  • Device: iPhone 12 Pro max
  • OS: iOS 14.2.1
@AlexV525
Copy link
Member

The files may downloading from the iCloud

@JimmyTai
Copy link
Author

@AlexV525

After test file getter and getMediaUrl() in AssetEntity, they return different file path.

  1. The file path from file getter
    /private/var/mobile/Containers/Data/Application/A106C2D9-2CEC-4638-A091-188C533DE4D2/tmp/.video/IMG_0084.MOV
  2. The file path from getMediaUrl()
    /var/mobile/Media/DCIM/100APPLE/IMG_0084.MOV

It seems getMediaUrl() return the file located in Gallery, but file getter return the file located in App temporary directory.

@AlexV525
Copy link
Member

AlexV525 commented Apr 6, 2021

Path is a simulated concept on all platforms, since they don't actually provide a real path that can be access directly.

@JimmyTai
Copy link
Author

JimmyTai commented Apr 16, 2021

After some research, I found fetchFullSizeVideo in PMManager.m will call itself in the progress handler when progress is 1.0. Then it will trigger ExportSession multiple times. After ExportSession create the local file, fetchFullSizeVideo can found the file in local storage and return the file path. But in the in the meantime, ExportSession haven't done the process. Therefore the file size keep changing.

The other problem. After requestAVAssetForVideo for iCloud file. It will trigger ExportSession immediately. But some times the processing fail. I found some guys are discussing about this in other GitHub repo (banchichen/TZImagePickerController#1073).

Now I use requestExportSessionForVideo instead of requestAVAssetForVideo to solve this problem.

I will create a PR, please help me to review it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants