mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Add trace markers for onScrollChanged / updateClippingRect (#46412)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/46412 These are quite useful when investigating scroll performance. Changelog: [internal] Reviewed By: rshest Differential Revision: D62213724 fbshipit-source-id: 3293aaf82584eae8508c748638c47c8b010db58f
This commit is contained in:
committed by
Facebook GitHub Bot
parent
274f5bfe6c
commit
94489d563d
+33
-20
@@ -62,6 +62,7 @@ import com.facebook.react.views.scroll.ReactScrollViewHelper.HasSmoothScroll;
|
||||
import com.facebook.react.views.scroll.ReactScrollViewHelper.HasStateWrapper;
|
||||
import com.facebook.react.views.scroll.ReactScrollViewHelper.ReactScrollViewScrollState;
|
||||
import com.facebook.react.views.view.ReactViewBackgroundManager;
|
||||
import com.facebook.systrace.Systrace;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -490,24 +491,30 @@ public class ReactHorizontalScrollView extends HorizontalScrollView
|
||||
FLog.i(TAG, "onScrollChanged[%d] x %d y %d oldx %d oldy %d", getId(), x, y, oldX, oldY);
|
||||
}
|
||||
|
||||
super.onScrollChanged(x, y, oldX, oldY);
|
||||
Systrace.beginSection(
|
||||
Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "ReactHorizontalScrollView.onScrollChanged");
|
||||
try {
|
||||
super.onScrollChanged(x, y, oldX, oldY);
|
||||
|
||||
mActivelyScrolling = true;
|
||||
mActivelyScrolling = true;
|
||||
|
||||
if (mOnScrollDispatchHelper.onScrollChanged(x, y)) {
|
||||
if (mRemoveClippedSubviews) {
|
||||
updateClippingRect();
|
||||
if (mOnScrollDispatchHelper.onScrollChanged(x, y)) {
|
||||
if (mRemoveClippedSubviews) {
|
||||
updateClippingRect();
|
||||
}
|
||||
if (mPreventReentry) {
|
||||
return;
|
||||
}
|
||||
mPreventReentry = true;
|
||||
ReactScrollViewHelper.updateStateOnScrollChanged(
|
||||
this,
|
||||
mOnScrollDispatchHelper.getXFlingVelocity(),
|
||||
mOnScrollDispatchHelper.getYFlingVelocity(),
|
||||
mEnableSyncOnScroll);
|
||||
mPreventReentry = false;
|
||||
}
|
||||
if (mPreventReentry) {
|
||||
return;
|
||||
}
|
||||
mPreventReentry = true;
|
||||
ReactScrollViewHelper.updateStateOnScrollChanged(
|
||||
this,
|
||||
mOnScrollDispatchHelper.getXFlingVelocity(),
|
||||
mOnScrollDispatchHelper.getYFlingVelocity(),
|
||||
mEnableSyncOnScroll);
|
||||
mPreventReentry = false;
|
||||
} finally {
|
||||
Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -783,12 +790,18 @@ public class ReactHorizontalScrollView extends HorizontalScrollView
|
||||
return;
|
||||
}
|
||||
|
||||
Assertions.assertNotNull(mClippingRect);
|
||||
Systrace.beginSection(
|
||||
Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "ReactHorizontalScrollView.updateClippingRect");
|
||||
try {
|
||||
Assertions.assertNotNull(mClippingRect);
|
||||
|
||||
ReactClippingViewGroupHelper.calculateClippingRect(this, mClippingRect);
|
||||
View contentView = getContentView();
|
||||
if (contentView instanceof ReactClippingViewGroup) {
|
||||
((ReactClippingViewGroup) contentView).updateClippingRect();
|
||||
ReactClippingViewGroupHelper.calculateClippingRect(this, mClippingRect);
|
||||
View contentView = getContentView();
|
||||
if (contentView instanceof ReactClippingViewGroup) {
|
||||
((ReactClippingViewGroup) contentView).updateClippingRect();
|
||||
}
|
||||
} finally {
|
||||
Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+32
-20
@@ -63,6 +63,7 @@ import com.facebook.react.views.scroll.ReactScrollViewHelper.HasSmoothScroll;
|
||||
import com.facebook.react.views.scroll.ReactScrollViewHelper.HasStateWrapper;
|
||||
import com.facebook.react.views.scroll.ReactScrollViewHelper.ReactScrollViewScrollState;
|
||||
import com.facebook.react.views.view.ReactViewBackgroundManager;
|
||||
import com.facebook.systrace.Systrace;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.List;
|
||||
|
||||
@@ -414,24 +415,29 @@ public class ReactScrollView extends ScrollView
|
||||
|
||||
@Override
|
||||
protected void onScrollChanged(int x, int y, int oldX, int oldY) {
|
||||
super.onScrollChanged(x, y, oldX, oldY);
|
||||
Systrace.beginSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "ReactScrollView.onScrollChanged");
|
||||
try {
|
||||
super.onScrollChanged(x, y, oldX, oldY);
|
||||
|
||||
mActivelyScrolling = true;
|
||||
mActivelyScrolling = true;
|
||||
|
||||
if (mOnScrollDispatchHelper.onScrollChanged(x, y)) {
|
||||
if (mRemoveClippedSubviews) {
|
||||
updateClippingRect();
|
||||
if (mOnScrollDispatchHelper.onScrollChanged(x, y)) {
|
||||
if (mRemoveClippedSubviews) {
|
||||
updateClippingRect();
|
||||
}
|
||||
if (mPreventReentry) {
|
||||
return;
|
||||
}
|
||||
mPreventReentry = true;
|
||||
ReactScrollViewHelper.updateStateOnScrollChanged(
|
||||
this,
|
||||
mOnScrollDispatchHelper.getXFlingVelocity(),
|
||||
mOnScrollDispatchHelper.getYFlingVelocity(),
|
||||
mEnableSyncOnScroll);
|
||||
mPreventReentry = false;
|
||||
}
|
||||
if (mPreventReentry) {
|
||||
return;
|
||||
}
|
||||
mPreventReentry = true;
|
||||
ReactScrollViewHelper.updateStateOnScrollChanged(
|
||||
this,
|
||||
mOnScrollDispatchHelper.getXFlingVelocity(),
|
||||
mOnScrollDispatchHelper.getYFlingVelocity(),
|
||||
mEnableSyncOnScroll);
|
||||
mPreventReentry = false;
|
||||
} finally {
|
||||
Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -543,12 +549,18 @@ public class ReactScrollView extends ScrollView
|
||||
return;
|
||||
}
|
||||
|
||||
Assertions.assertNotNull(mClippingRect);
|
||||
Systrace.beginSection(
|
||||
Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "ReactScrollView.updateClippingRect");
|
||||
try {
|
||||
Assertions.assertNotNull(mClippingRect);
|
||||
|
||||
ReactClippingViewGroupHelper.calculateClippingRect(this, mClippingRect);
|
||||
View contentView = getContentView();
|
||||
if (contentView instanceof ReactClippingViewGroup) {
|
||||
((ReactClippingViewGroup) contentView).updateClippingRect();
|
||||
ReactClippingViewGroupHelper.calculateClippingRect(this, mClippingRect);
|
||||
View contentView = getContentView();
|
||||
if (contentView instanceof ReactClippingViewGroup) {
|
||||
((ReactClippingViewGroup) contentView).updateClippingRect();
|
||||
}
|
||||
} finally {
|
||||
Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -30,8 +30,9 @@ import java.util.concurrent.CopyOnWriteArrayList
|
||||
|
||||
/** Helper class that deals with emitting Scroll Events. */
|
||||
public object ReactScrollViewHelper {
|
||||
private val TAG = ReactHorizontalScrollView::class.java.simpleName
|
||||
private val TAG = ReactScrollView::class.java.simpleName
|
||||
private val DEBUG_MODE = false // ReactBuildConfig.DEBUG
|
||||
|
||||
private const val CONTENT_OFFSET_LEFT = "contentOffsetLeft"
|
||||
private const val CONTENT_OFFSET_TOP = "contentOffsetTop"
|
||||
private const val SCROLL_AWAY_PADDING_TOP = "scrollAwayPaddingTop"
|
||||
|
||||
Reference in New Issue
Block a user