Skip to content

Bug: Crash on Synchronous VideoPlayerController Disposal #19

@windoze95

Description

@windoze95

Description

In lib/screens/video_player_screen.dart, the _switchToHq method synchronously disposes of the old VideoPlayerController right after calling setState():

      setState(() {
        _controller = hqController;
        _isPreviewMode = false;
      });

      oldController?.pause();
      oldController?.dispose();

Impact

This causes an assertion error (A VideoPlayerController was used after being disposed) because the widget tree hasn't fully unmounted the old VideoPlayer widget in the same frame, and listeners (ValueListenableBuilder) attached to it might still trigger updates.

Suggested Fix

Delay the disposal until the next frame using Future.microtask() or a timer, e.g., Future.delayed(const Duration(seconds: 1), () => oldController?.dispose());.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions