macOS: Do not use dispatch queue when canceling idle callback (flutter/engine#27732)

Fixes https://github.com/flutter/flutter/issues/86932

Relying on dispatch queue to bump call on main thread in this instance
is problematic because platform plugin can hold the dispatch queue.
Using performSelectorOnMainThread: instead works, because it is
processed by the CFRunLoop independent of dispatch queue.
This commit is contained in:
Matej Knopp
2021-07-27 23:06:17 +02:00
committed by GitHub
parent ca82f36e70
commit 9bfd5820b9

View File

@@ -92,9 +92,11 @@ static const double kIdleDelay = 1.0;
size:_surfaceSize];
}
};
dispatch_async(dispatch_get_main_queue(), ^{
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(onIdle) object:nil];
});
[self performSelectorOnMainThread:@selector(cancelIdle) withObject:nil waitUntilDone:NO];
}
- (void)cancelIdle {
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(onIdle) object:nil];
}
- (nonnull FlutterRenderBackingStore*)renderBuffer {