Skip to content

video_player plugin can cause a crash on iPhone X running iOS 12 when disposing the video controller #41125

@dannyvalentesonos

Description

@dannyvalentesonos

When popping a page that contains a video on it, and disposing of the video controller in the dispose method could very often cause a crash on an iPhoneX running iOS 12. This happens because the DisplayLink has notified the flutter Texture registry that a frame is ready, and the flutter GPU thread then tries to get the pixel buffer after the FLTVideoPlayer object has been destructed.

The following code leads to the problem:

import 'package:flutter/material.dart';
import 'package:video_player/video_player.dart';

class VideoCrashPlayerPage extends StatefulWidget {
  @override
  _VideoCrashPlayerPageState createState() => _VideoCrashPlayerPageState();
}

class _VideoCrashPlayerPageState extends State<VideoCrashPlayerPage> {
  
  VideoPlayerController _videoPlayerController;

  @override
  void initState() {
    super.initState();

    _videoPlayerController = VideoPlayerController.asset("videos/video.mp4");
    _videoPlayerController.addListener(() {
      if (!_videoPlayerController.value.isPlaying) {
        Navigator.pop(context);
      }
    });
    _videoPlayerController.play();
    _videoPlayerController.initialize();
  }

  @override
  void dispose() {
    _videoPlayerController.dispose();

    super.dispose();
  }

  @override
  Widget build(BuildContext context) {

    return Material(
        elevation: 0,
        child: Column(
          children: <Widget>[
            Expanded(
                child: FittedBox(
                  fit: BoxFit.cover,
                  child: Container(
                      width: 818.0,
                      height: 864.0,
                      child: VideoPlayer(_videoPlayerController)
                  ),
                )
            )
          ],
        )
    );
  }
}

Metadata

Metadata

Assignees

Labels

c: crashStack traces logged to the consolee: device-specificOnly manifests on certain devicesp: video_playerThe Video Player pluginpackageflutter/packages repository. See also p: labels.platform-iosiOS applications specificallywaiting for PR to land (fixed)A fix is in flight

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions