This repository was archived by the owner on Feb 25, 2025. It is now read-only.
File tree 2 files changed +19
-0
lines changed
shell/platform/darwin/macos/framework/Source
2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change 6
6
#import " flutter/shell/platform/darwin/macos/framework/Source/FlutterEngine_Internal.h"
7
7
8
8
#include < functional>
9
+ #include < thread>
9
10
10
11
#include " flutter/fml/synchronization/waitable_event.h"
11
12
#include " flutter/lib/ui/window/platform_message.h"
@@ -668,6 +669,19 @@ - (nonnull NSView*)createWithViewIdentifier:(int64_t)viewId arguments:(nullable
668
669
}
669
670
}
670
671
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
+
671
685
} // namespace flutter::testing
672
686
673
687
// 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 {
79
79
fml::AutoResetWaitableEvent event;
80
80
{
81
81
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
+ }
82
87
fml::AutoResetWaitableEvent& e = event;
83
88
_scheduledBlocks.push_back (^{
84
89
notify ();
You can’t perform that action at this time.
0 commit comments