Repository navigation
[video_player] VideoPlayerController::initialize future never resolves nor errors on iOS with the attached video file #166914
Copy link
Copy link
Closed
flutter/packages
#9534Labels
⏳Bot is counting down the days until it unassigns the issueBot is counting down the days until it unassigns the issueP2Important issues not at the top of the work listImportant issues not at the top of the work listfound in release: 3.29Found to occur in 3.29Found to occur in 3.29found in release: 3.31Found to occur in 3.31Found to occur in 3.31has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onp: video_playerThe Video Player pluginThe Video Player pluginpackageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.platform-iosiOS applications specificallyiOS applications specificallyteam-iosOwned by iOS platform teamOwned by iOS platform teamtriaged-iosTriaged by iOS platform teamTriaged by iOS platform team
Description
Steps to reproduce
- copy the attached video file into assets
- run the code sample
Tested also with the latest main branch of packages.
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 19H384Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
⏳Bot is counting down the days until it unassigns the issueBot is counting down the days until it unassigns the issueP2Important issues not at the top of the work listImportant issues not at the top of the work listfound in release: 3.29Found to occur in 3.29Found to occur in 3.29found in release: 3.31Found to occur in 3.31Found to occur in 3.31has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onp: video_playerThe Video Player pluginThe Video Player pluginpackageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.platform-iosiOS applications specificallyiOS applications specificallyteam-iosOwned by iOS platform teamOwned by iOS platform teamtriaged-iosTriaged by iOS platform teamTriaged by iOS platform team
Activity
maheshj01 commentedon Apr 10, 2025
Reproducible on stable and the master channel
flutter doctor -v
master
stable
[-][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[/+]1 remaining item
Balin-P commentedon Jun 2, 2025
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:
The codec of the video:

LongCatIsLooong commentedon Jul 1, 2025
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 ?
misos1 commentedon Jul 3, 2025
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
durationfor 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.LongCatIsLooong commentedon Jul 7, 2025
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.
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.misos1 commentedon Jul 10, 2025
@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
cameraplugin by changing line withvideoWriter?.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.
flutter-triage-bot commentedon Nov 10, 2025
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!
[video_player_avfoundation] removes unnecessary duration and size che…
github-actions commentedon Nov 25, 2025
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 -vand a minimal reproduction of the issue.[video_player_avfoundation] removes unnecessary duration and size che…
[video_player_avfoundation] removes unnecessary duration and size che…
[video_player_avfoundation] removes unnecessary duration and size che…
[video_player_avfoundation] removes unnecessary duration and size che…