File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed
shell/platform/darwin/macos/framework/Source Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change 66#import " flutter/shell/platform/darwin/macos/framework/Source/FlutterEngine_Internal.h"
77
88#include < functional>
9+ #include < thread>
910
1011#include " flutter/fml/synchronization/waitable_event.h"
1112#include " flutter/lib/ui/window/platform_message.h"
@@ -668,6 +669,19 @@ - (nonnull NSView*)createWithViewIdentifier:(int64_t)viewId arguments:(nullable
668669 }
669670}
670671
672+ TEST (EngineTest, ThreadSynchronizerNotBlockingRasterThreadAfterShutdown) {
673+ FlutterThreadSynchronizer* threadSynchronizer = [[FlutterThreadSynchronizer alloc ] init ];
674+ [threadSynchronizer shutdown ];
675+
676+ std::thread rasterThread ([&threadSynchronizer] {
677+ [threadSynchronizer performCommit: CGSizeMake (100 , 100 )
678+ notify: ^{
679+ }];
680+ });
681+
682+ rasterThread.join ();
683+ }
684+
671685} // namespace flutter::testing
672686
673687// NOLINTEND(clang-analyzer-core.StackAddressEscape)
Original file line number Diff line number Diff line change @@ -79,6 +79,11 @@ - (void)performCommit:(CGSize)size notify:(nonnull dispatch_block_t)notify {
7979 fml::AutoResetWaitableEvent event;
8080 {
8181 std::unique_lock<std::mutex> lock (_mutex);
82+ if (_shuttingDown) {
83+ // Engine is shutting down, main thread may be blocked by the engine
84+ // waiting for raster thread to finish.
85+ return ;
86+ }
8287 fml::AutoResetWaitableEvent& e = event;
8388 _scheduledBlocks.push_back (^{
8489 notify ();
You can’t perform that action at this time.
0 commit comments