Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@
using namespace facebook;
using namespace facebook::react;

#if RCT_DEBUG
#define ENABLE_DEBUG_LOGGING 0 && RCT_DEBUG

#if ENABLE_DEBUG_LOGGING
static void debugLog(NSString *msg, ...)
{
auto debugEnabled = ReactNativeFeatureFlags::enableVirtualViewDebugFeatures();
if (!debugEnabled) {
return;
}

va_list args;
va_start(args, msg);
NSString *msgString = [[NSString alloc] initWithFormat:msg arguments:args];
RCTLogInfo(@"%@", msgString);
va_end(args); // Don't forget to call va_end to clean up
}

#define DEBUG_LOG(...) debugLog(__VA_ARGS__)
#else
#define DEBUG_LOG(...) ((void)0)
#endif

/**
Expand Down Expand Up @@ -87,18 +87,14 @@ - (instancetype)initWithScrollView:(RCTScrollViewComponentView *)scrollView
_prerenderRatio = ReactNativeFeatureFlags::virtualViewPrerenderRatio();
[_scrollViewComponentView addScrollListener:self];

#if RCT_DEBUG
debugLog(@"initWithScrollView");
#endif
DEBUG_LOG(@"initWithScrollView");
}
return self;
}

- (void)dealloc
{
#if RCT_DEBUG
debugLog(@"dealloc");
#endif
DEBUG_LOG(@"dealloc");
if (_scrollViewComponentView != nil) {
[_scrollViewComponentView removeScrollListener:self];
_scrollViewComponentView = nil;
Expand All @@ -112,14 +108,9 @@ - (void)onChange:(id<RCTVirtualViewProtocol>)virtualView
{
if (![_virtualViews containsObject:virtualView]) {
[_virtualViews addObject:virtualView];
#if RCT_DEBUG
debugLog(@"Add virtualViewID=%@", virtualView.virtualViewID);
#endif

DEBUG_LOG(@"Add virtualViewID=%@", virtualView.virtualViewID);
} else {
#if RCT_DEBUG
debugLog(@"Update virtualViewID=%@", virtualView.virtualViewID);
#endif
DEBUG_LOG(@"Update virtualViewID=%@", virtualView.virtualViewID);
}
[self _updateModes:virtualView];
}
Expand All @@ -131,10 +122,7 @@ - (void)remove:(id<RCTVirtualViewProtocol>)virtualView
}

[_virtualViews removeObject:virtualView];

#if RCT_DEBUG
debugLog(@"Remove virtualViewID=%@", virtualView.virtualViewID);
#endif
DEBUG_LOG(@"Remove virtualViewID=%@", virtualView.virtualViewID);
}

#pragma mark - Private Helpers
Expand Down Expand Up @@ -169,14 +157,12 @@ - (void)_updateModes:(id<RCTVirtualViewProtocol>)virtualView
thresholdRect = _prerenderRect;
}

#if RCT_DEBUG
debugLog(
DEBUG_LOG(
@"UpdateModes virtualView=%@ mode=%ld rect=%@ thresholdRect=%@",
vv.virtualViewID,
(long)mode,
NSStringFromCGRect(rect),
NSStringFromCGRect(thresholdRect));
#endif
[vv onModeChange:mode targetRect:rect thresholdRect:thresholdRect];
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<8b35aa70eea734a8bfcbb7bd651ba8e2>>
* @generated SignedSource<<de3444d0862944a45bfb112e649dd395>>
*/

/**
Expand Down Expand Up @@ -144,12 +144,6 @@ public object ReactNativeFeatureFlags {
@JvmStatic
public fun enableDoubleMeasurementFixAndroid(): Boolean = accessor.enableDoubleMeasurementFixAndroid()

/**
* This infra allows native modules to initialize on the main thread, during React Native init.
*/
@JvmStatic
public fun enableEagerMainQueueModulesOnIOS(): Boolean = accessor.enableEagerMainQueueModulesOnIOS()

/**
* Feature flag to configure eager attachment of the root view/initialisation of the JS code.
*/
Expand Down Expand Up @@ -342,12 +336,6 @@ public object ReactNativeFeatureFlags {
@JvmStatic
public fun enableVirtualViewContainerStateExperimental(): Boolean = accessor.enableVirtualViewContainerStateExperimental()

/**
* Enables VirtualView debug features such as logging and overlays.
*/
@JvmStatic
public fun enableVirtualViewDebugFeatures(): Boolean = accessor.enableVirtualViewDebugFeatures()

/**
* Fix incorrect parentTag passed as parentTagForUpdate in the unflatten-unflatten branch of calculateShadowViewMutationsFlattener, which causes UPDATE mutations to reference a parent being created in the same batch.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<494ed85c58f80b4feb6fb9b83fe7a27e>>
* @generated SignedSource<<76c912049c6cbfac8bd0e27418dab700>>
*/

/**
Expand Down Expand Up @@ -39,7 +39,6 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces
private var enableDestroyShadowTreeRevisionAsyncCache: Boolean? = null
private var enableDifferentiatorMutationVectorPreallocationCache: Boolean? = null
private var enableDoubleMeasurementFixAndroidCache: Boolean? = null
private var enableEagerMainQueueModulesOnIOSCache: Boolean? = null
private var enableEagerRootViewAttachmentCache: Boolean? = null
private var enableExclusivePropsUpdateAndroidCache: Boolean? = null
private var enableFabricCommitBranchingCache: Boolean? = null
Expand Down Expand Up @@ -72,7 +71,6 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces
private var enableViewRecyclingForTextCache: Boolean? = null
private var enableViewRecyclingForViewCache: Boolean? = null
private var enableVirtualViewContainerStateExperimentalCache: Boolean? = null
private var enableVirtualViewDebugFeaturesCache: Boolean? = null
private var fixDifferentiatorParentTagForUnflattenCaseCache: Boolean? = null
private var fixMappingOfEventPrioritiesBetweenFabricAndReactCache: Boolean? = null
private var fixYogaFlexBasisFitContentInMainAxisCache: Boolean? = null
Expand Down Expand Up @@ -282,15 +280,6 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces
return cached
}

override fun enableEagerMainQueueModulesOnIOS(): Boolean {
var cached = enableEagerMainQueueModulesOnIOSCache
if (cached == null) {
cached = ReactNativeFeatureFlagsCxxInterop.enableEagerMainQueueModulesOnIOS()
enableEagerMainQueueModulesOnIOSCache = cached
}
return cached
}

override fun enableEagerRootViewAttachment(): Boolean {
var cached = enableEagerRootViewAttachmentCache
if (cached == null) {
Expand Down Expand Up @@ -579,15 +568,6 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces
return cached
}

override fun enableVirtualViewDebugFeatures(): Boolean {
var cached = enableVirtualViewDebugFeaturesCache
if (cached == null) {
cached = ReactNativeFeatureFlagsCxxInterop.enableVirtualViewDebugFeatures()
enableVirtualViewDebugFeaturesCache = cached
}
return cached
}

override fun fixDifferentiatorParentTagForUnflattenCase(): Boolean {
var cached = fixDifferentiatorParentTagForUnflattenCaseCache
if (cached == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<16ca9a4b47da90ea71300eb37287e28b>>
* @generated SignedSource<<425c8a86705214aa021e413211468e97>>
*/

/**
Expand Down Expand Up @@ -66,8 +66,6 @@ public object ReactNativeFeatureFlagsCxxInterop {

@DoNotStrip @JvmStatic public external fun enableDoubleMeasurementFixAndroid(): Boolean

@DoNotStrip @JvmStatic public external fun enableEagerMainQueueModulesOnIOS(): Boolean

@DoNotStrip @JvmStatic public external fun enableEagerRootViewAttachment(): Boolean

@DoNotStrip @JvmStatic public external fun enableExclusivePropsUpdateAndroid(): Boolean
Expand Down Expand Up @@ -132,8 +130,6 @@ public object ReactNativeFeatureFlagsCxxInterop {

@DoNotStrip @JvmStatic public external fun enableVirtualViewContainerStateExperimental(): Boolean

@DoNotStrip @JvmStatic public external fun enableVirtualViewDebugFeatures(): Boolean

@DoNotStrip @JvmStatic public external fun fixDifferentiatorParentTagForUnflattenCase(): Boolean

@DoNotStrip @JvmStatic public external fun fixMappingOfEventPrioritiesBetweenFabricAndReact(): Boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<10e6516b3c9cf53ae2e48c8b8cd51033>>
* @generated SignedSource<<30bd20f9479756c3dce574c05b80a1f4>>
*/

/**
Expand Down Expand Up @@ -61,8 +61,6 @@ public open class ReactNativeFeatureFlagsDefaults : ReactNativeFeatureFlagsProvi

override fun enableDoubleMeasurementFixAndroid(): Boolean = false

override fun enableEagerMainQueueModulesOnIOS(): Boolean = false

override fun enableEagerRootViewAttachment(): Boolean = false

override fun enableExclusivePropsUpdateAndroid(): Boolean = false
Expand Down Expand Up @@ -127,8 +125,6 @@ public open class ReactNativeFeatureFlagsDefaults : ReactNativeFeatureFlagsProvi

override fun enableVirtualViewContainerStateExperimental(): Boolean = false

override fun enableVirtualViewDebugFeatures(): Boolean = false

override fun fixDifferentiatorParentTagForUnflattenCase(): Boolean = false

override fun fixMappingOfEventPrioritiesBetweenFabricAndReact(): Boolean = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<441fe8be28d4521e1fe9fe7b87b74cf2>>
* @generated SignedSource<<e08b9d00abd67c312a50a5c893a91e1b>>
*/

/**
Expand Down Expand Up @@ -43,7 +43,6 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc
private var enableDestroyShadowTreeRevisionAsyncCache: Boolean? = null
private var enableDifferentiatorMutationVectorPreallocationCache: Boolean? = null
private var enableDoubleMeasurementFixAndroidCache: Boolean? = null
private var enableEagerMainQueueModulesOnIOSCache: Boolean? = null
private var enableEagerRootViewAttachmentCache: Boolean? = null
private var enableExclusivePropsUpdateAndroidCache: Boolean? = null
private var enableFabricCommitBranchingCache: Boolean? = null
Expand Down Expand Up @@ -76,7 +75,6 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc
private var enableViewRecyclingForTextCache: Boolean? = null
private var enableViewRecyclingForViewCache: Boolean? = null
private var enableVirtualViewContainerStateExperimentalCache: Boolean? = null
private var enableVirtualViewDebugFeaturesCache: Boolean? = null
private var fixDifferentiatorParentTagForUnflattenCaseCache: Boolean? = null
private var fixMappingOfEventPrioritiesBetweenFabricAndReactCache: Boolean? = null
private var fixYogaFlexBasisFitContentInMainAxisCache: Boolean? = null
Expand Down Expand Up @@ -305,16 +303,6 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc
return cached
}

override fun enableEagerMainQueueModulesOnIOS(): Boolean {
var cached = enableEagerMainQueueModulesOnIOSCache
if (cached == null) {
cached = currentProvider.enableEagerMainQueueModulesOnIOS()
accessedFeatureFlags.add("enableEagerMainQueueModulesOnIOS")
enableEagerMainQueueModulesOnIOSCache = cached
}
return cached
}

override fun enableEagerRootViewAttachment(): Boolean {
var cached = enableEagerRootViewAttachmentCache
if (cached == null) {
Expand Down Expand Up @@ -635,16 +623,6 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc
return cached
}

override fun enableVirtualViewDebugFeatures(): Boolean {
var cached = enableVirtualViewDebugFeaturesCache
if (cached == null) {
cached = currentProvider.enableVirtualViewDebugFeatures()
accessedFeatureFlags.add("enableVirtualViewDebugFeatures")
enableVirtualViewDebugFeaturesCache = cached
}
return cached
}

override fun fixDifferentiatorParentTagForUnflattenCase(): Boolean {
var cached = fixDifferentiatorParentTagForUnflattenCaseCache
if (cached == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<972dbaef144818484bafff334cf97ef2>>
* @generated SignedSource<<babb0304c7232e14d8dd807032bcbc53>>
*/

/**
Expand Down Expand Up @@ -61,8 +61,6 @@ public interface ReactNativeFeatureFlagsProvider {

@DoNotStrip public fun enableDoubleMeasurementFixAndroid(): Boolean

@DoNotStrip public fun enableEagerMainQueueModulesOnIOS(): Boolean

@DoNotStrip public fun enableEagerRootViewAttachment(): Boolean

@DoNotStrip public fun enableExclusivePropsUpdateAndroid(): Boolean
Expand Down Expand Up @@ -127,8 +125,6 @@ public interface ReactNativeFeatureFlagsProvider {

@DoNotStrip public fun enableVirtualViewContainerStateExperimental(): Boolean

@DoNotStrip public fun enableVirtualViewDebugFeatures(): Boolean

@DoNotStrip public fun fixDifferentiatorParentTagForUnflattenCase(): Boolean

@DoNotStrip public fun fixMappingOfEventPrioritiesBetweenFabricAndReact(): Boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ package com.facebook.react.views.scroll

import android.graphics.Rect
import android.view.ViewGroup
import com.facebook.common.logging.FLog
import com.facebook.react.common.build.ReactBuildConfig
import com.facebook.react.internal.featureflags.ReactNativeFeatureFlags
import com.facebook.react.views.virtual.VirtualViewMode
import java.util.*
Expand Down Expand Up @@ -69,24 +67,18 @@ internal abstract class VirtualViewContainerState {
}

open fun onChange(virtualView: VirtualView) {
if (virtualViews.add(virtualView)) {
debugLog("add", { "virtualViewID=${virtualView.virtualViewID}" })
} else {
debugLog("update", { "virtualViewID=${virtualView.virtualViewID}" })
}
virtualViews.add(virtualView)
updateModes(virtualView)
}

open fun remove(virtualView: VirtualView) {
assert(virtualViews.remove(virtualView)) {
"Attempting to remove non-existent VirtualView: ${virtualView.virtualViewID}"
}
debugLog("remove", { "virtualViewID=${virtualView.virtualViewID}" })
}

// Called on ScrollView onLayout or onScroll
fun updateState() {
debugLog("updateState")
updateModes()
}

Expand All @@ -98,7 +90,6 @@ internal abstract class VirtualViewContainerState {
// intentionally goes but curently ScrollView and v1 Fling use this check to determine if
// "content ready"
if (visibleRect.isEmpty()) {
debugLog("updateRects", { "scrollView visibleRect is empty" })
// should set the other rects here in case scrollview is suddenly empty after the other rects
// are non-empty
prerenderRect.set(visibleRect)
Expand All @@ -110,22 +101,7 @@ internal abstract class VirtualViewContainerState {
(-prerenderRect.width() * prerenderRatio).toInt(),
(-prerenderRect.height() * prerenderRatio).toInt(),
)

debugLog(
"updateRects",
{ "visibleRect ${visibleRect.toString()} prerenderRect ${prerenderRect.toString()}" },
)
}

protected abstract fun updateModes(virtualView: VirtualView? = null)
}

private const val DEBUG_TAG: String = "VirtualViewContainerState"
internal val IS_DEBUG_BUILD =
ReactBuildConfig.DEBUG || ReactBuildConfig.IS_INTERNAL_BUILD || ReactBuildConfig.ENABLE_PERFETTO

private inline fun debugLog(subtag: String, block: () -> String = { "" }) {
if (IS_DEBUG_BUILD && ReactNativeFeatureFlags.enableVirtualViewDebugFeatures()) {
FLog.d("$DEBUG_TAG:$subtag", block())
}
}
Loading
Loading