Fix video player crash
Describe the bug/problem
Launch API Dash
Paste the following URL in GET Request: https://flutter.github.io/assets-for-api-docs/assets/videos/bee.mp4
Hit Send
Once the response is received, the App crashes due to some error in VideoPreviewer - https://github.com/foss42/apidash/blob/main/lib/widgets/video_previewer.dart
This issue requires analysis of the root cause of the crash & potential fix.
Setup - Apple M1 (Sonoma 14.6.1)
% flutter doctor -v
[✓] Flutter (Channel stable, 3.29.0, on macOS 14.6.1 23G93 darwin-arm64, locale en-IN) [271ms]
• Flutter version 3.29.0 on channel stable at /Users/ap/Documents/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 35c388afb5 (3 weeks ago), 2025-02-10 12:48:41 -0800
• Engine revision f73bfc4522
• Dart version 3.7.0
• DevTools version 2.42.2
[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0) [1,143ms]
• Android SDK at /Users/ap/Library/Android/sdk
• Platform android-35, build-tools 35.0.0
• 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 17.0.11+0-17.0.11b1207.24-11852314)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 15.4) [603ms]
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 15F31d
• CocoaPods version 1.16.2
[✓] Chrome - develop for the web [28ms]
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2024.1) [28ms]
• 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)
[✓] IntelliJ IDEA Community Edition (version 2023.1.2) [27ms]
• IntelliJ at /Applications/IntelliJ IDEA CE.app
• 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
[✓] VS Code (version 1.97.2) [9ms]
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.104.0
[✓] Connected device (3 available) [6.9s]
• macOS (desktop) • macos • darwin-arm64 • macOS 14.6.1 23G93 darwin-arm64
• Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin • macOS 14.6.1 23G93 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 133.0.6943.142
or associated
with the same local area network as this Mac.
The device must be opted into Developer Mode to connect wirelessly. (code -27)
[✓] Network resources [410ms]
• All expected network resources are available.
• No issues found!
@ashitaprasad i am working on this issue
Thanks @AffanShaikhsurab
Interested to work on this, Can I work too on this issue @ashitaprasad ?
as i am not able to reproduce the issue in windows can you please let me knowif you were using web / windows / android it would be a great help @ashitaprasad
Thanks for investigating @AffanShaikhsurab The issue was observed in macOS platform and is yet to be checked on other platforms.
Interested to work on this, Can I work too on this issue @ashitaprasad ?
@akshayw1 Do you use macOS?
i have check on android and windows and there is no issue there !! looks like its an mac specific issue but need to be tested on linux !!
Since I don't have access to macOS, I might be limited in resolving this issue effectively. it would be better for member with the appropriate setup to take this up!
Interested to work on this, Can I work too on this issue @ashitaprasad ?
@akshayw1 Do you use macOS?
Yes, I use macOs air m2
@akshayw1 can you please check the logs and inspect what might have causing the issue ?
Hi @ashitaprasad I tried reproducing this issue on a arm silicon (M3) based mac. The video previewer seemed to be working fine in this case. I have also tested another endpoint that serves .mp4 file, it worked for that as well.
System: Sequoia macOS 15.3.1 Flutter Version: 3.29.0 Dart SDK version: 3.7.0
PFA video demonstration:
https://github.com/user-attachments/assets/14a31ecb-90e3-4b37-9eb6-9898f3534108
Let me know if you need me to try any other scenario.
Thanks!
@ashitaprasad can you please specify what was the env that caused the issue ?
@divyanshkul are you running it on the latest HEAD of the main branch?
@ashitaprasad can you please specify what was the env that caused the issue ?
Updated the Issue description with all the details.
@ashitaprasad Yes, I was running the latest HEAD till this 79788dc64e43d8bf0a2dc72056a1781be5c24cb4
[✓] Flutter (Channel stable, 3.29.0, on macOS 15.3.1 24D70 darwin-arm64, locale
en-IN) [1,031ms]
• Flutter version 3.29.0 on channel stable at
/Users/divyansh/development/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 35c388afb5 (3 weeks ago), 2025-02-10 12:48:41 -0800
• Engine revision f73bfc4522
• Dart version 3.7.0
• DevTools version 2.42.2
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0) [2.4s]
• Android SDK at /Users/divyansh/Library/Android/sdk
• Platform android-34, build-tools 34.0.0
• 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 17.0.11+0-17.0.11b1207.24-11852314)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 16.0) [2.2s]
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 16A242d
• CocoaPods version 1.16.2
[✓] Chrome - develop for the web [9ms]
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2024.1) [9ms]
• 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)
[✓] VS Code (version 1.97.2) [8ms]
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.104.0```
@ashitaprasad Yes, I was running the latest HEAD till this 79788dc
Thanks for confirming @divyanshkul
Hi @ashitaprasad , I tried to reproduce the issue locally (head till 1618b6c) with: System: macOS 15.3.1 (24D70) Darwin-arm64 (Rosetta) (M2) Flutter Version: 3.29.0 Dart SDK Version: 3.7.0 The preview was working fine, and no issues were found. Let me know if there’s anything else I can check or any other scenario I can test to help.
Hi @ashitaprasad,
I have tested this issue on Windows, and I was able to reproduce it.
Findings: When the API Dash window is in normal size, the video previewer works correctly, allowing playback and controls. When maximizing the window, the video freezes in the UI, but in the Flutter terminal logs, playback continues in the background. The issue is not a crash, but rather a UI rendering issue triggered by window resizing. System Details: OS: Windows Flutter Version: 3.29.0 Dart SDK Version: 3.7.0 (stable) Solution: I analyzed the root cause and found that the issue is due to video player rendering not updating correctly on resize events. After applying one update in the code, I was able to fix the issue.
Would love to discuss further and contribute the fix! Let me know if I should open a PR. 🚀
https://github.com/user-attachments/assets/645ca64d-9324-490f-805e-481ee14f0470
HI @ashitaprasad I am willing to work on this
Hi @ashitaprasad I tried reproducing this issue on a arm silicon (M3) based mac. The video previewer seemed to be working fine in this case. I have also tested another endpoint that serves .mp4 file, it worked for that as well.
System: Sequoia macOS 15.3.1 Flutter Version: 3.29.0 Dart SDK version: 3.7.0
PFA video demonstration: test.mp4
Let me know if you need me to try any other scenario.
Thanks!
I was also looking at this issue .. I tried some fixes and then i noticed another bug.. switch to headers tab(Next to Response Body) then switch back to Response body.. this causes another crash.. I was testing it on linux Ubuntu 24.04.1 LTS. I think the widget is getting disposed then a update is being made to the widget But the widget is not in widget tree
@ashitaprasad I identified the cause and fixed it . Will hit PR soon.. got some things to do Currently
ok @badnikhil
Hi @ashitaprasad,
I have tested this issue. Updating Flutter and Dart to the latest stable versions resolves the issue by ensuring proper rendering updates.
Let me know if further verification is needed.
is this issue closed?
If the previous filed PR didnt meet the requirements just let me know, ill start working on this issue! @ashitaprasad