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 report] cannot access video format in iOS 18 Live Photo #1196

Closed
dodatw opened this issue Oct 9, 2024 · 9 comments · Fixed by #1213
Closed

[Bug report] cannot access video format in iOS 18 Live Photo #1196

dodatw opened this issue Oct 9, 2024 · 9 comments · Fixed by #1213

Comments

@dodatw
Copy link

dodatw commented Oct 9, 2024

Version

3.5.0

Platforms

iOS

Device Model

iPhone 15 (iOS 18)

flutter info

[✓] Flutter (Channel stable, 3.24.3, on macOS 15.0.1 24A348 darwin-arm64,
    locale zh-Hant-TW)
    • Flutter version 3.24.3 on channel stable at
      /Users/rdapp/fvm/versions/stable
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 2663184aa7 (4 周前), 2024-09-11 16:27:48 -0500
    • Engine revision 36335019a8
    • Dart version 3.5.3
    • DevTools version 2.37.3
    • Pub download mirror http://app-pub-pc01.pft.com:8080

[✓] Android toolchain - develop for Android devices (Android SDK version
    33.0.2)
    • Android SDK at /Users/rdapp/Library/Android/sdk
    • Platform android-34, build-tools 33.0.2
    • Java binary at: /Applications/Android
      Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build
      17.0.11+0-17.0.11b1207.24-11852314)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 16.0)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 16A242d
    • CocoaPods version 1.15.2

[✓] Android Studio (version 2024.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build
      17.0.11+0-17.0.11b1207.24-11852314)

[✓] Connected device (4 available)
    • Pixel 7 (mobile)                • 2A141FDH2003LG            •
      android-arm64 • Android 14 (API 34)
    • Tommy’s iPhone (mobile)         • 00008130-0002212810EB8D3A • ios
      • iOS 18.0.1 22A3370
    • macOS (desktop)                 • macos                     •
      darwin-arm64  • macOS 15.0.1 24A348 darwin-arm64
    • Mac Designed for iPad (desktop) • mac-designed-for-ipad     • darwin
      • macOS 15.0.1 24A348 darwin-arm64

[✓] Network resources
    • All expected network resources are available.

How to reproduce?

After upgrade to iOS 18, I want to Live Photo in video, seem not work anymore.

getMediaUrl => "file:///var/mobile/Media/DCIM/117APPLE/IMG_7666.MOV"
Exception when play this video: PlatformException(VideoError, Failed to load video: The file couldn’t be opened because you don’t have permission to view it., null, null)

I also tried fileWithSubtype
fileWithSubtype => file: File: '/private/var/mobile/Containers/Data/Application/973F8808-BD05-4354-9C1A-FA9CAC5A3AF9/tmp/.video/A10CB802-AB97-48D3-AF8C-9FB5D270BCBB_L0_001_1728264640.877920_o_IMG_7666.MOV'
Exception when play this video: PlatformException(VideoError, Failed to load video: Operation Stopped, null, null)

Is there any special porting need finish in iOS 18?
It play normal at iOS 17 (by getMediaUrl)

Logs

No response

Example code (optional)

No response

Contact

No response

@dodatw dodatw changed the title [Bug report] iOS 18 Live Photo [Bug report] cannot access video format in iOS 18 Live Photo Oct 9, 2024
@AlexV525
Copy link
Member

AlexV525 commented Oct 9, 2024

@dodatw
Copy link
Author

dodatw commented Oct 9, 2024

miguelpruivo/flutter_file_picker#612 (comment)

I think it should be different issue.
It still can reproduce after reboot.
This issue can reproduce more than one device. All devices are iOS 18.

@AlexV525
Copy link
Member

AlexV525 commented Oct 9, 2024

We don't have iOS 18 devices around, unfortunately.

@AlexV525
Copy link
Member

AlexV525 commented Oct 9, 2024

How about video assets? Do they played well on iOS 18?

@dodatw
Copy link
Author

dodatw commented Oct 10, 2024

How about video assets? Do they played well on iOS 18?

Video Assets can play without issue.

@shanxus
Copy link

shanxus commented Oct 29, 2024

The video url of live photo is got from the "privateFileURL".

(void)getMediaUrl:(NSString *)assetId
      resultHandler:(NSObject <PMResultHandler> *)handler
    progressHandler:(NSObject <PMProgressHandlerProtocol> *)progressHandler

if (@available(iOS 9.1, *)) {
        if ((asset.mediaSubtypes & PHAssetMediaSubtypePhotoLive) == PHAssetMediaSubtypePhotoLive) {
            PHAssetResource *resource = [asset getLivePhotosResource];
            NSURL *url = [resource valueForKey:@"privateFileURL"];
            if (url) {
                [handler reply:url.absoluteString];
                return;
            }
            [self fetchLivePhotosFile:asset handler:handler progressHandler:progressHandler withScheme:YES fileType:nil];
            return;
        }
    }
...

In iOS 18, if the "privateFileURL" is used to init the AVURLAsset and AVPlayerItem, the status of AVPlayerItem will be always AVPlayerItemStatusFailed and the video can not start to play.

In the other hand, the video url got from the following functions should work.

[self fetchLivePhotosFile:asset handler:handler progressHandler:progressHandler withScheme:YES fileType:nil];

@AlexV525
Copy link
Member

@dodatw Could you help to confirm if the above comment works in your case?

@dodatw
Copy link
Author

dodatw commented Oct 29, 2024

Hi Alex,

it is work if I call this function directlly

[self fetchLivePhotosFile:asset handler:handler progressHandler:progressHandler withScheme:YES fileType:nil];

Is it possiable fix in photo_manager ?
ex, check if iOS 18 don't call these function

            PHAssetResource *resource = [asset getLivePhotosResource];
            NSURL *url = [resource valueForKey:@"privateFileURL"];
            if (url) {
                [handler reply:url.absoluteString];
                return;
            }

@AlexV525
Copy link
Member

AlexV525 commented Oct 29, 2024

Please apply the snippet until we fix this in the future release.

// https://github.com/fluttercandies/flutter_photo_manager/issues/1196
if (@available(iOS 18.0, *)) {
    [self fetchLivePhotosFile:asset handler:handler progressHandler:progressHandler withScheme:YES fileType:nil];
    return;
}
PHAssetResource *resource = [asset getLivePhotosResource];
NSURL *url = [resource valueForKey:@"privateFileURL"];
if (url) {
    [handler reply:url.absoluteString];
    return;
}
[self fetchLivePhotosFile:asset handler:handler progressHandler:progressHandler withScheme:YES fileType:nil];
return;

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

Successfully merging a pull request may close this issue.

3 participants