Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/video_player/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.10.2+3

* iOS: Fix an issue where video_player plugin can cause a crash on iPhone X running iOS 12 when disposing the video controller.

## 0.10.2+2

* Update and migrate iOS example project.
Expand Down
12 changes: 11 additions & 1 deletion packages/video_player/ios/Classes/VideoPlayerPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -483,11 +483,21 @@ - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
} else {
NSDictionary* argsMap = call.arguments;
int64_t textureId = ((NSNumber*)argsMap[@"textureId"]).unsignedIntegerValue;
FLTVideoPlayer* player = _players[@(textureId)];
__block FLTVideoPlayer* player = _players[@(textureId)];
if ([@"dispose" isEqualToString:call.method]) {
[_registry unregisterTexture:textureId];
[_players removeObjectForKey:@(textureId)];
[player dispose];

// TODO: remove the line below when the race condition is resolved:
// https://github.com/flutter/flutter/issues/41125
// Hang on to the player for a second to give time for the texture to grab the last buffer
// This can happen if the display link just notified that a frame was ready before this dispose gets called
// In this case, even though we unregister the texture id, the gpu thread has been scheduled to grab the buffer
// and if the player is deallocated, we'll crash
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
player = nil;
});
result(nil);
} else if ([@"setLooping" isEqualToString:call.method]) {
[player setIsLooping:[argsMap[@"looping"] boolValue]];
Expand Down
2 changes: 1 addition & 1 deletion packages/video_player/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: video_player
description: Flutter plugin for displaying inline video with other Flutter
widgets on Android and iOS.
author: Flutter Team <flutter-dev@googlegroups.com>
version: 0.10.2+2
version: 0.10.2+3
homepage: https://github.com/flutter/plugins/tree/master/packages/video_player

flutter:
Expand Down