From 70b5eb3aa27822fa11571c3d8d3628ecf03268ab Mon Sep 17 00:00:00 2001 From: Thomas BARRAS Date: Mon, 15 Oct 2018 18:07:07 -0700 Subject: [PATCH] ListView requestAnimationFrame leak (#21802) Summary: Related to https://github.com/facebook/react-native/pull/21488 Disclaimer: I made this PR. I think there's some requestAnimationFrame events that are not cleared on unmount because of bad use of `splice` method. - All flow tests succeed. - RNTester: iOS (this change should only affect iOS because calculateChildFrames is iOS only) Show perf monitor, show ListView* screen, start scrolling. UI frame Rate is used at the beginning. When scrolling there is no drop in FPS rate. - TODO: I'll write a load test for ListView [GENERAL] [ENHANCEMENT] [ListView.js] - rm TimerMixin Pull Request resolved: https://github.com/facebook/react-native/pull/21802 Differential Revision: D10391812 Pulled By: RSNara fbshipit-source-id: 49f0b0a4641ec29bcb4cc04bd3bafb42b3842b69 --- Libraries/Lists/ListView/ListView.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Libraries/Lists/ListView/ListView.js b/Libraries/Lists/ListView/ListView.js index 9d1443e8fe484e..409cd228ea475f 100644 --- a/Libraries/Lists/ListView/ListView.js +++ b/Libraries/Lists/ListView/ListView.js @@ -544,7 +544,7 @@ const ListView = createReactClass({ _requestAnimationFrame: function(fn: () => void): void { const rafId = requestAnimationFrame(() => { - this._rafIds.splice(this._rafIds.indexOf(rafId)); + this._rafIds = this._rafIds.filter(id => id !== rafId); fn(); }); this._rafIds.push(rafId);