File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed
shell/platform/darwin/macos/framework/Source Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -429,7 +429,11 @@ - (BOOL)launchEngine {
429
429
// ViewController as a listener for a keyUp event before it's handled by NSApplication, and should
430
430
// NOT modify the event to avoid any unexpected behavior.
431
431
- (void )listenForMetaModifiedKeyUpEvents {
432
- NSAssert (_keyUpMonitor == nil , @" _keyUpMonitor was already created" );
432
+ if (_keyUpMonitor != nil ) {
433
+ // It is possible for [NSViewController viewWillAppear] to be invoked multiple times
434
+ // in a row. https://github.com/flutter/flutter/issues/105963
435
+ return ;
436
+ }
433
437
FlutterViewController* __weak weakSelf = self;
434
438
_keyUpMonitor = [NSEvent
435
439
addLocalMonitorForEventsMatchingMask: NSEventMaskKeyUp
Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ - (bool)testKeyEventsAreNotPropagatedIfHandled;
22
22
- (bool )testFlagsChangedEventsArePropagatedIfNotHandled ;
23
23
- (bool )testKeyboardIsRestartedOnEngineRestart ;
24
24
- (bool )testTrackpadGesturesAreSentToFramework ;
25
+ - (bool )testViewWillAppearCalledMultipleTimes ;
25
26
26
27
+ (void )respondFalseForSendEvent : (const FlutterKeyEvent&)event
27
28
callback : (nullable FlutterKeyEventCallback)callback
@@ -134,6 +135,10 @@ + (void)respondFalseForSendEvent:(const FlutterKeyEvent&)event
134
135
ASSERT_TRUE ([[FlutterViewControllerTestObjC alloc ] testTrackpadGesturesAreSentToFramework ]);
135
136
}
136
137
138
+ TEST (FlutterViewControllerTest, testViewWillAppearCalledMultipleTimes) {
139
+ ASSERT_TRUE ([[FlutterViewControllerTestObjC alloc ] testViewWillAppearCalledMultipleTimes ]);
140
+ }
141
+
137
142
} // namespace flutter::testing
138
143
139
144
@implementation FlutterViewControllerTestObjC
@@ -518,4 +523,14 @@ - (bool)testTrackpadGesturesAreSentToFramework {
518
523
return true ;
519
524
}
520
525
526
+ - (bool )testViewWillAppearCalledMultipleTimes {
527
+ id engineMock = OCMClassMock ([FlutterEngine class ]);
528
+ FlutterViewController* viewController = [[FlutterViewController alloc ] initWithEngine: engineMock
529
+ nibName: @" "
530
+ bundle: nil ];
531
+ [viewController viewWillAppear ];
532
+ [viewController viewWillAppear ];
533
+ return true ;
534
+ }
535
+
521
536
@end
You can’t perform that action at this time.
0 commit comments