Skip to content

Commit

Permalink
macOS: Do not use dispatch queue when canceling idle callback (flutte…
Browse files Browse the repository at this point in the history
…r#27732)

Fixes flutter/flutter#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.
  • Loading branch information
knopp authored Jul 27, 2021
1 parent 29790e3 commit 506ee40
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,11 @@ - (void)ensureBackBuffer {
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 {
Expand Down

0 comments on commit 506ee40

Please sign in to comment.