Skip to content

[video_player] VideoPlayerController.initialize() never return if the file is invalid (text file) #147707

Open

Description

@stephane-archer

Steps to reproduce

on mac os

      VideoPlayerController controller = VideoPlayerController.file(file);
      await controller.initialize();

if file is a .fish file (a shell script that is not a video but a text file) await controller.initialize(); will never return or throw an exception, you wait indefinitely...

Expected results

if the file is not a video it should throw an exception

Actual results

up

Code sample

Code sample
[Paste your code here]

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
[Paste your output here]

Activity

  1. darshankawar commented on May 2, 2024

    @darshankawar
    Member

    Thanks for the report @stephane-archer
    I tried a sample text file with plugin's example with which I received below log:

    Caused by: com.google.android.exoplayer2.source.UnrecognizedInputFormatException: None of the available extractors (FlvExtractor, FlacExtractor, WavExtractor, FragmentedMp4Extractor, Mp4Extractor, AmrExtractor, PsExtractor, OggExtractor, TsExtractor, MatroskaExtractor, AdtsExtractor, Ac3Extractor, Ac4Extractor, Mp3Extractor, AviExtractor, JpegExtractor) could read the stream.
    E/ExoPlayerImplInternal(29974):       at com.google.android.exoplayer2.source.BundledExtractorsAdapter.init(BundledExtractorsAdapter.java:92)
    E/ExoPlayerImplInternal(29974):       at com.google.android.exoplayer2.source.ProgressiveMediaPeriod$ExtractingLoadable.load(ProgressiveMediaPeriod.java:1017)
    E/ExoPlayerImplInternal(29974):       at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:412)
    E/ExoPlayerImplInternal(29974):       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137)
    E/ExoPlayerImplInternal(29974):       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637)
    E/ExoPlayerImplInternal(29974):       at java.lang.Thread.run(Thread.java:1012)
    E/flutter (29974): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(VideoError, Video player had error com.google.android.exoplayer2.ExoPlaybackException: Source error, null, null)
    E/flutter (29974): 
    

    Do you see same exception ? It does throw .UnrecognizedInputFormatException which seem to be expected as the file passed is non-video file.

  2. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on May 2, 2024
  3. stephane-archer commented on May 2, 2024

    @stephane-archer
    Author

    @darshankawar I don't see any exception on MacOS. await controller.initialize(); never finish.
    You should probably do the same test on MacOS

  4. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on May 2, 2024
  5. darshankawar commented on May 3, 2024

    @darshankawar
    Member

    I tried plugin example and ran (basic.dart) on desktop and used below sample non-video file which gave me below exception:

    https://example-files.online-convert.com/document/txt/example.txt',

    https://github.com/flutter/packages/blob/f4719ca2feffe9831c42371488f179b438a1cdf8/packages/video_player/video_player/example/lib/basic.dart#L30

    [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(VideoError, Failed to load video: Operation Stopped, null, null)

    Does it represent your case ?

  6. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on May 3, 2024
  7. stephane-archer commented on May 3, 2024

    @stephane-archer
    Author

    no, await controller.initialize(); never return, throw, or finish in any way. the code is just blocked here forever.
    I think this should at least timeout.

    Screenshot 2024-05-04 at 00 13 35 Screenshot 2024-05-04 at 00 13 38 Screenshot 2024-05-04 at 00 13 40 Screenshot 2024-05-04 at 00 13 51
  8. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on May 3, 2024
  9. stephane-archer commented on May 3, 2024

    @stephane-archer
    Author

    in this case, the file is: "/Volumes/Macintosh HD/Users/fractale/Desktop/proxy_research/benchmarktorun.fish"
    it has execution permission and the content is:

    #!/usr/bin/env fish
    # ffmpeg -i a.mov -vcodec prores_ks -profile:v 0 -vf scale=-1:540 btmp.mov
    hyperfine --warmup 5  --prepare 'rm btmp.mov || true' 'ffmpeg -i a.mov -vcodec prores_ks -profile:v 0 -vf scale=-1:540 btmp.mov' 'ffmpeg -i a.mov -vcodec prores_ks -profile:v 1 -vf scale=-1:540 btmp.mov' 'ffmpeg -i a.mov -vcodec prores_ks -profile:v 2 -vf scale=-1:540 btmp.mov' 'ffmpeg -i a.mov -vcodec prores_ks -profile:v 3 -vf scale=-1:540 btmp.mov' 'ffmpeg -i a.mov -vcodec prores_ks -profile:v 4 -vf scale=-1:540 btmp.mov' 'ffmpeg -i a.mov -vcodec prores_ks -profile:v 5 -vf scale=-1:540 btmp.mov'
    
    
  10. darshankawar commented on May 6, 2024

    @darshankawar
    Member

    Thanks for the update. Keeping the issue open for tracking.

  11. 14 remaining items

  12. added
    P2Important issues not at the top of the work list
    on May 13, 2024
  13. stuartmorgan-g commented on May 13, 2024

    @stuartmorgan-g
    Contributor

    Currently the way the plugin is designed, initialize completion is driven by event channel callbacks rather than an async method channel response, which makes it easy to never resolve the callback. It looks like what happens here is probably than we send an error event to the stream, but never associate it with initialize.

    In the short term we could potentially work around it with a new event stream type just for initialization errors, but we should redesign the flow for initialize in general to use a response.

  14. stephane-archer commented on May 13, 2024

    @stephane-archer
    Author

    @stuartmorgan is there anything I can run to help you understand better the issue?

  15. stuartmorgan-g commented on Nov 22, 2024

    @stuartmorgan-g
  16. ddikman commented on May 26, 2025

    @ddikman
  17. choim4389 commented on Oct 24, 2025

    @choim4389
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listp: video_playerThe Video Player pluginpackageflutter/packages repository. See also p: labels.team-ecosystemOwned by Ecosystem teamtriaged-ecosystemTriaged by Ecosystem team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions