@@ -126,6 +126,12 @@ - (void)initialize
126126 name: RCTBridgeWillInvalidateModulesNotification
127127 object: nil ];
128128
129+ [self invalidateCachedConstants ];
130+ }
131+
132+ - (void )invalidateCachedConstants
133+ {
134+ RCTAssertMainQueue ();
129135 _constants = @{
130136 @" Dimensions" : [self _exportedDimensions ],
131137 // Note:
@@ -244,20 +250,24 @@ - (NSDictionary *)_exportedDimensions
244250
245251- (void )didReceiveNewContentSizeMultiplier
246252{
247- __weak __typeof (self) weakSelf = self;
253+ [self invalidateCachedConstants ];
254+ NSDictionary *nextInterfaceDimensions = _constants[@" Dimensions" ];
255+
248256 RCTModuleRegistry *moduleRegistry = _moduleRegistry;
249257 RCTExecuteOnMainQueue (^{
250258 // Report the event across the bridge.
251259#pragma clang diagnostic push
252260#pragma clang diagnostic ignored "-Wdeprecated-declarations"
253261 [[moduleRegistry moduleForName: " EventDispatcher" ] sendDeviceEventWithName: @" didUpdateDimensions"
254- body: [weakSelf _exportedDimensions ] ];
262+ body: nextInterfaceDimensions ];
255263#pragma clang diagnostic pop
256264 });
257265}
258266
259267- (void )interfaceOrientationDidChange
260268{
269+ [self invalidateCachedConstants ];
270+
261271#if TARGET_OS_IOS && !TARGET_OS_MACCATALYST
262272 UIWindow *window = RCTKeyWindow ();
263273 UIInterfaceOrientation nextOrientation = window.windowScene .interfaceOrientation ;
@@ -279,8 +289,9 @@ - (void)interfaceOrientationDidChange
279289 if ((isOrientationChanging || isResizingOrChangingToFullscreen) && RCTIsAppActive ()) {
280290#pragma clang diagnostic push
281291#pragma clang diagnostic ignored "-Wdeprecated-declarations"
292+ NSDictionary *nextInterfaceDimensions = _constants[@" Dimensions" ];
282293 [[_moduleRegistry moduleForName: " EventDispatcher" ] sendDeviceEventWithName: @" didUpdateDimensions"
283- body: [ self _exportedDimensions ] ];
294+ body: nextInterfaceDimensions ];
284295 // We only want to track the current _currentInterfaceOrientation and _isFullscreen only
285296 // when it happens and only when it is published.
286297 _currentInterfaceOrientation = nextOrientation;
@@ -300,7 +311,8 @@ - (void)interfaceFrameDidChange
300311
301312- (void )_interfaceFrameDidChange
302313{
303- NSDictionary *nextInterfaceDimensions = [self _exportedDimensions ];
314+ [self invalidateCachedConstants ];
315+ NSDictionary *nextInterfaceDimensions = _constants[@" Dimensions" ];
304316
305317 // update and publish the even only when the app is in active state
306318 if (!([nextInterfaceDimensions isEqual: _currentInterfaceDimensions]) && RCTIsAppActive ()) {
0 commit comments