mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-24 04:16:00 +08:00
Temporary low risk workaround for killing image network requests in rnfeed.
Summary: View the comment thread for discussion: https://www.facebook.com/groups/1505872839725322/permalink/1630102823968989 Our current behaviour of add then immediately remove if a view is clipped pretty much guarantees that we kill network requests for images in feed. We have a better fix for that in the pipeline, but this is a low risk fix in the meantime. Reviewed By: ahmedre Differential Revision: D3597785
This commit is contained in:
committed by
Ahmed El-Helw
parent
70fb45393e
commit
8564fc074b
@@ -416,7 +416,11 @@ import com.facebook.react.views.view.ReactClippingViewGroupHelper;
|
|||||||
@Override
|
@Override
|
||||||
protected void onDetachedFromWindow() {
|
protected void onDetachedFromWindow() {
|
||||||
if (!mIsAttached) {
|
if (!mIsAttached) {
|
||||||
throw new RuntimeException("Double detach");
|
// Hack. Our current behaviour of add then immediately remove if a view is clipped pretty
|
||||||
|
// much guarantees that we kill network requests for images in feed. We have a fix, but are
|
||||||
|
// going to add it in master and patch this in in the meantime.
|
||||||
|
return;
|
||||||
|
// throw new RuntimeException("Double detach");
|
||||||
}
|
}
|
||||||
|
|
||||||
mIsAttached = false;
|
mIsAttached = false;
|
||||||
@@ -877,18 +881,17 @@ import com.facebook.react.views.view.ReactClippingViewGroupHelper;
|
|||||||
// Now off the screen. Don't invalidate in this case, as the canvas should not be
|
// Now off the screen. Don't invalidate in this case, as the canvas should not be
|
||||||
// redrawn unless new elements are coming onscreen.
|
// redrawn unless new elements are coming onscreen.
|
||||||
mClippedSubviews.put(view.getId(), view);
|
mClippedSubviews.put(view.getId(), view);
|
||||||
removeViewsInLayout(--index, 1);
|
detachViewFromParent(--index);
|
||||||
drawView.isViewGroupClipped = true;
|
drawView.isViewGroupClipped = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Clipped, invisible.
|
// Clipped, invisible.
|
||||||
if (withinBounds(view, clippingRect)) {
|
if (withinBounds(view, clippingRect)) {
|
||||||
// Now on the screen. Invalidate as we have a new element to draw.
|
// Now on the screen. Invalidate as we have a new element to draw.
|
||||||
addViewInLayout(
|
attachViewToParent(
|
||||||
view,
|
view,
|
||||||
index++,
|
index++,
|
||||||
ensureLayoutParams(view.getLayoutParams()),
|
ensureLayoutParams(view.getLayoutParams()));
|
||||||
true);
|
|
||||||
mClippedSubviews.remove(view.getId());
|
mClippedSubviews.remove(view.getId());
|
||||||
drawView.isViewGroupClipped = false;
|
drawView.isViewGroupClipped = false;
|
||||||
needsInvalidate = true;
|
needsInvalidate = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user