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:
Seth Kirby
2016-07-20 23:27:34 -07:00
committed by Ahmed El-Helw
parent 70fb45393e
commit 8564fc074b

View File

@@ -416,7 +416,11 @@ import com.facebook.react.views.view.ReactClippingViewGroupHelper;
@Override
protected void onDetachedFromWindow() {
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;
@@ -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
// redrawn unless new elements are coming onscreen.
mClippedSubviews.put(view.getId(), view);
removeViewsInLayout(--index, 1);
detachViewFromParent(--index);
drawView.isViewGroupClipped = true;
}
} else {
// Clipped, invisible.
if (withinBounds(view, clippingRect)) {
// Now on the screen. Invalidate as we have a new element to draw.
addViewInLayout(
attachViewToParent(
view,
index++,
ensureLayoutParams(view.getLayoutParams()),
true);
ensureLayoutParams(view.getLayoutParams()));
mClippedSubviews.remove(view.getId());
drawView.isViewGroupClipped = false;
needsInvalidate = true;