未验证 提交 ece98584 编写于 作者: M Matej Knopp 提交者: GitHub

Unblock FlutterResizeSynchronizer on engine shutdown (#24264)

上级 6993cb22
......@@ -489,6 +489,10 @@ static void OnPlatformMessage(const FlutterPlatformMessage* message, FlutterEngi
return;
}
if (_viewController && _viewController.flutterView) {
[_viewController.flutterView shutdown];
}
FlutterEngineResult result = _embedderAPI.Deinitialize(_engine);
if (result != kSuccess) {
NSLog(@"Could not de-initialize the Flutter engine: error %d", result);
......
......@@ -75,4 +75,9 @@
*/
- (void)requestCommit;
/**
* Called when shutting down. Unblocks everything and prevents any further synchronization.
*/
- (void)shutdown;
@end
......@@ -34,6 +34,9 @@
// Target size for resizing.
CGSize _newSize;
// if YES prevents all synchronization
BOOL _shuttingDown;
__weak id<FlutterResizeSynchronizerDelegate> _delegate;
}
@end
......@@ -54,7 +57,7 @@
return;
}
if (!_receivedFirstFrame) {
if (!_receivedFirstFrame || _shuttingDown) {
// No blocking until framework produces at least one frame
notify();
return;
......@@ -77,7 +80,7 @@
_waiting = YES;
_condBlockRequestCommit.wait(lock, [&] { return _pendingCommit; });
_condBlockRequestCommit.wait(lock, [&] { return _pendingCommit || _shuttingDown; });
[_delegate resizeSynchronizerFlush:self];
[_delegate resizeSynchronizerCommit:self];
......@@ -104,7 +107,7 @@
- (void)requestCommit {
std::unique_lock<std::mutex> lock(_mutex);
if (!_acceptingCommit) {
if (!_acceptingCommit || _shuttingDown) {
return;
}
......@@ -113,7 +116,7 @@
_pendingCommit = YES;
if (_waiting) { // BeginResize is in progress, interrupt it and schedule commit call
_condBlockRequestCommit.notify_all();
_condBlockBeginResize.wait(lock, [&]() { return !_pendingCommit; });
_condBlockBeginResize.wait(lock, [&]() { return !_pendingCommit || _shuttingDown; });
} else {
// No resize, schedule commit on platform thread and wait until either done
// or interrupted by incoming BeginResize
......@@ -128,8 +131,15 @@
_condBlockBeginResize.notify_all();
}
});
_condBlockBeginResize.wait(lock, [&]() { return !_pendingCommit; });
_condBlockBeginResize.wait(lock, [&]() { return !_pendingCommit || _shuttingDown; });
}
}
- (void)shutdown {
std::unique_lock<std::mutex> lock(_mutex);
_shuttingDown = YES;
_condBlockBeginResize.notify_all();
_condBlockRequestCommit.notify_all();
}
@end
......@@ -56,4 +56,10 @@
*/
- (nonnull FlutterRenderBackingStore*)backingStoreForSize:(CGSize)size;
/**
* Must be called when shutting down. Unblocks raster thread and prevents any further
* synchronization.
*/
- (void)shutdown;
@end
......@@ -124,4 +124,8 @@
[_reshapeListener viewDidReshape:self];
}
- (void)shutdown {
[_resizeSynchronizer shutdown];
}
@end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册