Repository navigation
Description
Steps to reproduce
iOS 16.2, iphone14 Pro Max
In some cases, setting the wrong video composition parameter can cause the app to crash. I got a crash report, but I don't have the video to reproduce the problem.
https://github.com/flutter/packages/blob/6b024cab554c519c19a4e16f6a1142bb7b20681a/packages/video_player/video_player_avfoundation/darwin/video_player_avfoundation/Sources/video_player_avfoundation/FVPVideoPlayerPlugin.m#L294
It is possible to replicate the problem with the wrong parameter Settings, although this approach is not very appropriate
videoComposition.renderSize = CGSizeMake(1920, 0); // or other
item.videoComposition = videoComposition;
We should check the validity of the parameters here.I am not familiar with the code design of this plugin, and I am not clear about what kind of AVPlayer should be returned after getting an exception.We should deal with it.
https://github.com/flutter/packages/blob/6b024cab554c519c19a4e16f6a1142bb7b20681a/packages/video_player/video_player_avfoundation/darwin/video_player_avfoundation/Sources/video_player_avfoundation/FVPVideoPlayerPlugin.m#L211
Expected results
Application don't crashed.
Actual results
Application crashed.
Code sample
Code sample
[Paste your code here]Screenshots or Video
Screenshots / Video demonstration
[Upload media here]
Logs
Logs
libc++abi: terminating with uncaught exception of type NSException
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[AVPlayerItem setVideoComposition:] video composition must have a positive renderSize'
terminating with uncaught exception of type NSException
CoreSimulator 857.14 - Device: iPhone 14 Pro Max (F24BF7F8-F42C-412B-B330-667120A94C13) - Runtime: iOS 16.2 (20C52) - DeviceType: iPhone 14 Pro Max
Last Exception Backtrace:
0 CoreFoundation 0x18cb2cf20 __exceptionPreprocess + 164 (NSException.m:249)
1 libobjc.A.dylib 0x1849de018 objc_exception_throw + 60 (objc-exception.mm:356)
2 AVFCore 0x19e46e0f4 -[AVPlayerItem setVideoComposition:] + 432 (AVPlayerItem.m:0)
3 video_player_avfoundation 0x104e469d4 0x104e40000 + 27092
4 libdispatch.dylib 0x1949d013c _dispatch_call_block_and_release + 32 (init.c:1530)
5 libdispatch.dylib 0x1949d1dd4 _dispatch_client_callout + 20 (object.m:576)
6 libdispatch.dylib 0x1949d9400 _dispatch_lane_serial_drain + 748 (queue.c:3900)
7 libdispatch.dylib 0x1949d9f64 _dispatch_lane_invoke + 432 (queue.c:3991)
8 libdispatch.dylib 0x1949e4cb4 _dispatch_root_queue_drain_deferred_wlh + 288 (queue.c:6998)
9 libdispatch.dylib 0x1949e4528 _dispatch_workloop_worker_thread + 404 (queue.c:6592)
10 libsystem_pthread.dylib 0x1e9983934 _pthread_wqthread + 288 (pthread.c:2696)
11 libsystem_pthread.dylib 0x1e99800cc start_wqthread + 8 (:-1)
Thread 14 name:
Thread 14 Crashed:
0 libsystem_kernel.dylib 0x00000001d5be742c __pthread_kill + 8 (:-1)
1 libsystem_pthread.dylib 0x00000001e9986c0c pthread_kill + 268 (pthread.c:1721)
2 libsystem_c.dylib 0x0000000194a8aba0 abort + 180 (abort.c:118)
3 libc++abi.dylib 0x00000001e98a4ca4 abort_message + 132 (abort_message.cpp:78)
4 libc++abi.dylib 0x00000001e9894e5c demangling_terminate_handler() + 348 (cxa_default_handlers.cpp:77)
5 libobjc.A.dylib 0x00000001849f9e2c _objc_terminate() + 144 (objc-exception.mm:496)
6 libc++abi.dylib 0x00000001e98a4068 std::__terminate(void (*)()) + 16 (cxa_handlers.cpp:59)
7 libc++abi.dylib 0x00000001e98a400c std::terminate() + 108 (cxa_handlers.cpp:88)
8 libdispatch.dylib 0x00000001949d1de8 _dispatch_client_callout + 40 (object.m:579)
9 libdispatch.dylib 0x00000001949d9400 _dispatch_lane_serial_drain + 748 (queue.c:3900)
10 libdispatch.dylib 0x00000001949d9f64 _dispatch_lane_invoke + 432 (queue.c:3991)
11 libdispatch.dylib 0x00000001949e4cb4 _dispatch_root_queue_drain_deferred_wlh + 288 (queue.c:6998)
12 libdispatch.dylib 0x00000001949e4528 _dispatch_workloop_worker_thread + 404 (queue.c:6592)
13 libsystem_pthread.dylib 0x00000001e9983934 _pthread_wqthread + 288 (pthread.c:2696)
14 libsystem_pthread.dylib 0x00000001e99800cc start_wqthread + 8 (:-1)Flutter Doctor output
Doctor output
┌─────────────────────────────────────────────────────────┐
│ A new version of Flutter is available! │
│ │
│ To update to the latest version, run "flutter upgrade". │
└─────────────────────────────────────────────────────────┘
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.7.12, on macOS 12.6 21G115 darwin-arm64, locale
zh-Hans-CN)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 14.2)
[✗] Chrome - develop for the web (Cannot find Chrome executable at
/Applications/Google Chrome.app/Contents/MacOS/Google Chrome)
! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[✓] Android Studio (version 2021.2)
[✓] IntelliJ IDEA Community Edition (version 2022.1.4)
[✓] VS Code (version 1.90.0)
[✓] Connected device (2 available)
HTTP Host availability check is taking a long time...[!] HTTP Host Availability
✗ HTTP host "https://maven.google.com/" is not reachable. Reason: An error
occurred while checking the HTTP host: Operation timed out
✗ HTTP host "https://cloud.google.com/" is not reachable. Reason: An error
occurred while checking the HTTP host: Operation timed out
! Doctor found issues in 2 categories.
Activity
[-][Video player]Invalid videoComposition may cause the app crash[/-][+][video_player]Invalid videoComposition may cause the app crash[/+]danagbemava-nc commentedon Jul 1, 2024
Hi @lxhlzyh, do you know the type of video that causes this crash to occur? Do you also by any chance know the values that were passed that caused the crash?
lxhlzyh commentedon Jul 1, 2024
I don't know anything else about the video that led to the crash. The log shows that the crash occurred in AVPlayerItem setVideoComposition.However, there is also information about this in AVFoundation's AVPlayerItem.h.
If the user provides relevant video information, I will be the first time to upload here.
danagbemava-nc commentedon Jul 2, 2024
@lxhlzyh thanks for the update. One more thing, is there a more detailed crash log that you can share with us?
lxhlzyh commentedon Jul 2, 2024
@danagbemava-nc Sure, I updated the log entry above. You can see the crash backtrace and the thread stack.
danagbemava-nc commentedon Jul 3, 2024
Labeling this based on the crash log provided above.
3 remaining items
lxhlzyh commentedon Jul 3, 2024
Update, on macOS same.
PR: flutter/packages#7050
LouiseHsu commentedon Jul 24, 2024
@stuartmorgan is crashing the expected behavior when we pass in invalid parameters? if so maybe we should close this issue.
stuartmorgan-g commentedon Jul 24, 2024
No, we should essentially never crash. If we can't prevent this case with input validation (it's unclear to me if this is bad client params, or bad video data), we should be catching the exception and sending the error back to the Dart side.
florianthiel commentedon May 9, 2025
I have the same issue. But I am getting a
video composition must have a positive frameDurationcrash. The video is stored on Firebase storage and was created using Agora.io's MediaRecorder feature. I've attached a sample video that caused a crash. On Android everything is working fine.JaPOVUxtw1uwtySAhjim.mp4
zhangzhoufeng commentedon Jun 6, 2025
hello 我这里的这条网络视频报相同的错误
https://assets.picwand.cloud/video/visitor/enhance/2025-06-06/9501d407c22948468860aa20f2a1480e/5218a5dd-74e4-48ab-8ddd-485b7ace5d3a.MOV
您可以下载分析一下
ananya-pathak-sndk commentedon Sep 18, 2025
Hi, I have a similar issue. And I am getting a
video composition must have a positive frameDurationcrash. Is their anyway we can handle this?HatsuneMikuV commentedon Jan 27, 2026
Any updates? Regarding the
video composition must have a positive frameDurationcrash issue.Demo:
TestVideoCrashDemo.zip
@stuartmorgan-g @danagbemava-nc
Additionally, video_player_avfoundation 2.7.0 will not crash.
neeraj-pilot commentedon May 18, 2026
I have a concrete media sample and the track values for one reproducible case of this crash.
Package/platform:
video_playervideo_player_avfoundationvideo_player2.10.0andvideo_player_avfoundation2.7.2Media type:
.LS.mp4file, which is the Pixel/Google Long Shot motion-photo video container variantPXL_20250903_025523900.LS.mp4Repro code:
Actual result:
The process aborts while initializing the controller:
The crashing path is:
The relevant media values I observed from an AVFoundation probe:
CMTIME_IS_VALID(videoTrack.minFrameDuration)returns true for0/90000, so the current code uses it here:However,
0/90000is not a valid positive frame duration forAVMutableVideoComposition.frameDuration, and AVFoundation throws when the composition is assigned to the player item.I verified this with a small Objective-C AVFoundation repro that follows the same sequence as
FVPVideoPlayer:AVURLAsset.preferredTransform.AVMutableVideoComposition.videoComposition.frameDuration = videoTrack.minFrameDuration.item.videoComposition = videoComposition.For the
.LS.mp4file this throws with the positiveframeDurationexception. If the fallback is changed to treat zero duration as invalid, the same probe succeeds:This looks like a more specific variant of this issue: the input is not a manually invalid render size, but real video metadata where
minFrameDurationis a validCMTimewith a zero value.Relevant dependency versions from
pubspec.lock:Flutter doctor from the local macOS repro machine:
[video_player] Fix crash when videoTrack has zero-duration minFrameDu…