mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Set initial maximum surface size to viewport size
Summary:
Changelog: [internal]
There is a possibility of race between JavaScript sending "completeRoot" and maximum size set on surface. To prevent this race, we set the initial maximum size to be equal to the viewport size.
Alternative solution is to set maximumSize to {0, 0} initially instead of infinity. This is what old architecture does, even though not explicitly.
Reviewed By: fkgozali
Differential Revision: D30402207
fbshipit-source-id: 44427404eaf060a81de257797823edf971ffc1bb
This commit is contained in:
committed by
Facebook GitHub Bot
parent
1036c14888
commit
c2b971d6d4
@@ -16,6 +16,12 @@ RCT_EXTERN NSString *const RCTUserInterfaceStyleDidChangeNotificationTraitCollec
|
||||
RCT_EXTERN BOOL RCTExperimentGetPreemptiveViewAllocationDisabled(void);
|
||||
RCT_EXTERN void RCTExperimentSetPreemptiveViewAllocationDisabled(BOOL value);
|
||||
|
||||
/*
|
||||
* Initial maximum surface size
|
||||
*/
|
||||
RCT_EXTERN BOOL RCTGetInitialMaxSizeEnabled(void);
|
||||
RCT_EXTERN void RCTSetInitialMaxSizeEnabled(BOOL value);
|
||||
|
||||
/*
|
||||
* Remove clipped subviews
|
||||
*/
|
||||
|
||||
@@ -25,6 +25,21 @@ void RCTExperimentSetPreemptiveViewAllocationDisabled(BOOL value)
|
||||
RCTExperimentPreemptiveViewAllocationDisabled = value;
|
||||
}
|
||||
|
||||
/*
|
||||
* Initial maximum surface size
|
||||
*/
|
||||
static BOOL RCTInitialMaxSizeEnabled = NO;
|
||||
|
||||
BOOL RCTGetInitialMaxSizeEnabled()
|
||||
{
|
||||
return RCTInitialMaxSizeEnabled;
|
||||
}
|
||||
|
||||
void RCTSetInitialMaxSizeEnabled(BOOL value)
|
||||
{
|
||||
RCTInitialMaxSizeEnabled = value;
|
||||
}
|
||||
|
||||
/*
|
||||
* Remove clipped subviews
|
||||
*/
|
||||
|
||||
@@ -259,6 +259,10 @@ static BackgroundExecutor RCTGetBackgroundExecutor()
|
||||
RCTSetRemoveClippedSubviewsEnabled(YES);
|
||||
}
|
||||
|
||||
if (reactNativeConfig && reactNativeConfig->getBool("react_fabric:enable_initial_max_size_ios")) {
|
||||
RCTSetInitialMaxSizeEnabled(YES);
|
||||
}
|
||||
|
||||
auto componentRegistryFactory =
|
||||
[factory = wrapManagedObject(_mountingManager.componentViewRegistry.componentViewFactory)](
|
||||
EventDispatcher::Weak const &eventDispatcher, ContextContainer::Shared const &contextContainer) {
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#import <mutex>
|
||||
|
||||
#import <React/RCTAssert.h>
|
||||
#import <React/RCTConstants.h>
|
||||
#import <React/RCTConversions.h>
|
||||
#import <React/RCTFollyConvert.h>
|
||||
#import <React/RCTI18nUtil.h>
|
||||
@@ -60,6 +61,10 @@ using namespace facebook::react;
|
||||
|
||||
[_surfacePresenter registerSurface:self];
|
||||
|
||||
if (RCTGetInitialMaxSizeEnabled()) {
|
||||
[self setMinimumSize:CGSizeZero maximumSize:RCTViewportSize()];
|
||||
}
|
||||
|
||||
[self _updateLayoutContext];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
|
||||
Reference in New Issue
Block a user