Skip to content

[video_player] VideoPlayerController::initialize future never resolves nor errors on iOS with the attached video file #166914

Closed
flutter/packages
#9534

Description

@misos1

Steps to reproduce

  1. copy the attached video file into assets
  2. run the code sample

Tested also with the latest main branch of packages.

https://github.com/flutter/packages/blob/431dc61cadd586f753c89ee5e9da6bbef6dad964/packages/video_player/video_player_avfoundation/darwin/video_player_avfoundation/Sources/video_player_avfoundation/FVPVideoPlayer.m#L385-L387

Is this really a good idea?

Expected results

It should also print flutter: initialized or perhaps end with an unhandled exception.

Actual results

It prints just "flutter: constructed".

Code sample

Code sample
import "package:flutter/material.dart";
import "package:video_player/video_player.dart";

void main() async
{
	WidgetsFlutterBinding.ensureInitialized();
	var vpc = VideoPlayerController.asset("assets/fail.mp4");
	print("constructed");
	await vpc.initialize();
	print("initialized");
}

Video used in the code sample as fail.mp4

Video used in the code sample as fail.mp4
fail.mp4

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.27.2, on macOS 15.3.1 24D70 darwin-x64)
    • Flutter version 3.27.2 on channel stable at /usr/local/Caskroom/flutter/3.22.1/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 68415ad1d9 (3 months ago), 2025-01-13 10:22:03 -0800
    • Engine revision e672b006cb
    • Dart version 3.6.1
    • DevTools version 2.40.2

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

[✓] Connected device
    • ios            • iOS 15.8.2 19H384

Activity

  1. maheshj01 commented on Apr 10, 2025

    @maheshj01
    Member

    Reproducible on stable and the master channel

    Running Xcode build...                                                  
     └─Compiling, linking and signing...                         3.9s
    Xcode build done.                                           18.4s
    flutter: constructed
    Syncing files to device iPhone 15 Pro...                            46ms
    
    Flutter run key commands.
    r Hot reload. 🔥🔥🔥
    R Hot restart.
    h List all available interactive commands.
    d Detach (terminate "flutter run" but leave application running).
    c Clear the screen
    q Quit (terminate the application on the device).
    
    A Dart VM Service on iPhone 15 Pro is available at: http://127.0.0.1:49757/BvvVf4uHqGw=/
    The Flutter DevTools debugger and profiler on iPhone 15 Pro is available at:
    http://127.0.0.1:9101?uri=http://127.0.0.1:49757/BvvVf4uHqGw=/
    
    Performing hot restart...                                               
    Restarted application in 568ms.
    flutter: constructed
    
    
    flutter doctor -v

    master

    ✓] Flutter (Channel master, 3.31.0-1.0.pre.345, on macOS 15.1.1 24B2091 darwin-arm64, locale en-US) [2.6s]
        • Flutter version 3.31.0-1.0.pre.345 on channel master at /Users/mahesh/Development/flutter_master
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 9ce60b743d (2 hours ago), 2025-03-31 23:50:27 +0300
        • Engine revision 9ce60b743d
        • Dart version 3.8.0 (build 3.8.0-245.0.dev)
        • DevTools version 2.45.0-dev.0
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0) [3.1s]
        • Android SDK at /Users/mahesh/Library/Android/sdk
        • Platform android-35, build-tools 35.0.0
        • ANDROID_HOME = /Users/mahesh/Library/Android/sdk
        • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
          This is the JDK bundled with the latest Android Studio installation on this machine.
          To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
        • Java version OpenJDK Runtime Environment (build 21.0.5+-12932927-b750.29)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 16.0) [1,745ms]
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Build 16A242d
        • CocoaPods version 1.16.2
    
    [✓] Chrome - develop for the web [147ms]
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 2024.3) [146ms]
        • 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 21.0.5+-12932927-b750.29)
    
    [✓] IntelliJ IDEA Community Edition (version 2021.2.1) [144ms]
        • IntelliJ at /Applications/IntelliJ IDEA CE.app
        • Flutter plugin version 61.2.4
        • Dart plugin version 212.5080.8
    
    [✓] VS Code (version 1.96.2) [19ms]
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.102.0
    
    [✓] Connected device (2 available) [7.0s]
        • macOS (desktop) • macos  • darwin-arm64   • macOS 15.1.1 24B2091 darwin-arm64
        • Chrome (web)    • chrome • web-javascript • Google Chrome 131.0.6778.265
    
    [✓] Network resources [688ms]
        • All expected network resources are available.
    
    • No issues found!

    stable

    [✓] Flutter (Channel stable, 3.29.2, on macOS 15.1.1 24B2091 darwin-arm64, locale en-US) [822ms]
        • Flutter version 3.29.2 on channel stable at /Users/mahesh/Development/flutter
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision c236373904 (2 weeks ago), 2025-03-13 16:17:06 -0400
        • Engine revision 18b71d647a
        • Dart version 3.7.2
        • DevTools version 2.42.3
    [✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0) [3.2s]
        • Android SDK at /Users/mahesh/Library/Android/sdk
        • Platform android-35, build-tools 35.0.0
        • ANDROID_HOME = /Users/mahesh/Library/Android/sdk
        • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
          This is the JDK bundled with the latest Android Studio installation on this machine.
          To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
        • Java version OpenJDK Runtime Environment (build 21.0.5+-12932927-b750.29)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 16.0) [3.1s]
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Build 16A242d
        • CocoaPods version 1.16.2
    
    [✓] Chrome - develop for the web [136ms]
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 2024.3) [135ms]
        • 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 21.0.5+-12932927-b750.29)
    
    [✓] IntelliJ IDEA Community Edition (version 2021.2.1) [134ms]
        • IntelliJ at /Applications/IntelliJ IDEA CE.app
        • Flutter plugin version 61.2.4
        • Dart plugin version 212.5080.8
    
    [✓] VS Code (version 1.96.2) [18ms]
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.102.0
    
    [✓] Connected device (4 available) [6.7s]
        • iPad Pro 11-inch (M4) (mobile)  • A97192B5-5CFD-4164-BF2A-A6E2972614FF • ios            • com.apple.CoreSimulator.SimRuntime.iOS-18-0
          (simulator)
        • macOS (desktop)                 • macos                                • darwin-arm64   • macOS 15.1.1 24B2091 darwin-arm64
        • Mac Designed for iPad (desktop) • mac-designed-for-ipad                • darwin         • macOS 15.1.1 24B2091 darwin-arm64
        • Chrome (web)                    • chrome                               • web-javascript • Google Chrome 131.0.6778.265
    
    [✓] Network resources [294ms]
        • All expected network resources are available.
    
    ! Doctor found issues in 1 category.
  2. added
    packageflutter/packages repository. See also p: labels.
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    and removed
    in triagePresently being triaged by the triage team
    on Apr 10, 2025
  3. added
    team-iosOwned by iOS platform team
    platform-iosiOS applications specifically
    and removed on Apr 15, 2025
  4. changed the title [-][video_player_avfoundation] VideoPlayerController::initialize future never resolves nor errors with the attached video file[/-] [+][video_player] VideoPlayerController::initialize future never resolves nor errors on iOS with the attached video file[/+] on Apr 15, 2025
  5. added
    P2Important issues not at the top of the work list
    triaged-iosTriaged by iOS platform team
    on May 15, 2025
  6. 1 remaining item

  7. Balin-P commented on Jun 2, 2025

    @Balin-P

    I just ran into this as well. It's only one video in my app that has this issue. It just gets stuck loading forever, no logs or anything.

    Flutter Doctor:

    [✓] Flutter (Channel stable, 3.32.0, on macOS 15.5 24F74 darwin-arm64, locale en-AU) [1,255ms]
        • Flutter version 3.32.0 on channel stable at /Users/albertoshea/flutter/flutter
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision be698c48a6 (13 days ago), 2025-05-19 12:59:14 -0700
        • Engine revision 1881800949
        • Dart version 3.8.0
        • DevTools version 2.45.1
    
    [✗] Android toolchain - develop for Android devices [1,224ms]
        ✗ Unable to locate Android SDK.
          Install Android Studio from: https://developer.android.com/studio/index.html
          On first launch it will assist you in installing the Android SDK components.
          (or visit https://flutter.dev/to/macos-android-setup for detailed instructions).
          If the Android SDK has been installed to a custom location, please use
          `flutter config --android-sdk` to update to that location.
    
    
    [✓] Xcode - develop for iOS and macOS (Xcode 16.4) [2.5s]
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Build 16F6
        • CocoaPods version 1.16.2
    
    [✗] Chrome - develop for the web (Cannot find Chrome executable at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome) [11ms]
        ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
    
    [!] Android Studio (not installed) [10ms]
        • Android Studio not found; download from https://developer.android.com/studio/index.html
          (or visit https://flutter.dev/to/macos-android-setup for detailed instructions).
    
    [✓] VS Code (version 1.100.2) [10ms]
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.110.0
    
    [✓] Connected device (2 available) [6.0s]
        • Digital Services iPad (mobile) • 00008103-000A61EE11C3001E • ios          • iOS 16.3 20D47
        • macOS (desktop)                • macos                     • darwin-arm64 • macOS 15.5 24F74 darwin-arm64
    
    [✓] Network resources [1,120ms]
        • All expected network resources are available.
    
    ! Doctor found issues in 3 categories.
    

    The codec of the video:
    Image

  8. LongCatIsLooong commented on Jul 1, 2025

    @LongCatIsLooong
    Contributor

    This might partially be a problem with AVFoundation itself, as the video is playable in chrome but if you download it and play it quicktime the duration of the video is 0. However I couldn't create a video with 0 duration like the one posted for testing, any pointers @misos1 ?

  9. misos1 commented on Jul 3, 2025

    @misos1
    Author

    Duration is not 0, just AVFoundation somehow "mis-calculates" it. Audio samples are shifted against video samples. Do you really need to have a generator for such videos? In the description I did not want to suggest that checking duration for 0 should be removed, is that really a good idea? There may be cases when it is 0 for some moment even though status is ready to play. I saw that it may change between various values for some videos at the start if I remember correctly.

  10. LongCatIsLooong commented on Jul 7, 2025

    @LongCatIsLooong
    Contributor

    I wanted to write a test for my PR so I needed an 0-duration video to verify that works. But if the 0 duration is indeed due to a bug and can't happen naturally in a video then the test is probably of limited value.

    There may be cases when it is 0 for some moment even though status is ready to play.

    Do you know of any such cases? Apple's sample app https://developer.apple.com/library/archive/samplecode/AVPlayerDemo/Listings/Classes_AVPlayerDemoPlaybackViewController_m.html#//apple_ref/doc/uid/DTS40010101-Classes_AVPlayerDemoPlaybackViewController_m-DontLinkElementID_8 seems to imply that duration should be ready when the item is .readyToPlay. I'd be very surprised if the duration check is actually needed, as it's undocumented AFAIK and it's tied to crucial use cases of AVFoundation.

  11. misos1 commented on Jul 10, 2025

    @misos1
    Author

    @LongCatIsLooong I forgot how exactly that video was made but after a little experimenting it seems similar one can be generated using the example app in the camera plugin by changing line with

    videoWriter?.startSession(atSourceTime: currentSampleTime)

    to

    videoWriter?.startSession(atSourceTime: currentSampleTime + CMTimeMake(value: 1000, timescale: 1))

    in CameraPlugin.swift.

    And yes those checks look suspicious. I just supposed someone had good reason to add them due to maybe some bug in avfoundation.

  12. added
    ⏳Bot is counting down the days until it unassigns the issue
    on Nov 10, 2025
  13. flutter-triage-bot commented on Nov 10, 2025

    @flutter-triage-bot

    This issue is assigned to @LongCatIsLooong but has had no recent status updates. Please consider unassigning this issue if it is not going to be addressed in the near future. This allows people to have a clearer picture of what work is actually planned. Thanks!

  14. github-actions commented on Nov 25, 2025

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  15. locked as resolved and limited conversation to collaborators on Nov 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

⏳Bot is counting down the days until it unassigns the issueP2Important issues not at the top of the work listfound in release: 3.29Found to occur in 3.29found in release: 3.31Found to occur in 3.31has reproducible stepsThe issue has been confirmed reproducible and is ready to work onp: video_playerThe Video Player pluginpackageflutter/packages repository. See also p: labels.platform-iosiOS applications specificallyteam-iosOwned by iOS platform teamtriaged-iosTriaged by iOS platform team

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions