From 480dabd66547a60522249eda203a3eb1934b02e5 Mon Sep 17 00:00:00 2001 From: Tim Yung Date: Fri, 13 Nov 2020 18:04:51 -0800 Subject: [PATCH] RN: Remove Android `setTimeout` Warning Summary: Many third-party libraries (especially data management and caching ones) make use of long timeouts. There are currently no plans to change `setTimeout` on Android to support firing when apps are in the background. In the meantime, this warning is not actionable for developers who are using these frameworks. Their workarounds are to 1) deal with the noise in their logs, or 2) suppress the warning. Changelog: [General][Removed] - Removed warning on Android for `setTimeout` with delays greater than 1 minute. Reviewed By: lunaleaps Differential Revision: D24964958 fbshipit-source-id: 1b40c8ba95d554c29dec74477aa63ea3ef8e4768 --- Libraries/Core/Timers/JSTimers.js | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/Libraries/Core/Timers/JSTimers.js b/Libraries/Core/Timers/JSTimers.js index 9c5d2a099e3887..504daa5f446193 100644 --- a/Libraries/Core/Timers/JSTimers.js +++ b/Libraries/Core/Timers/JSTimers.js @@ -11,7 +11,6 @@ 'use strict'; const BatchedBridge = require('../../BatchedBridge/BatchedBridge'); -const Platform = require('../../Utilities/Platform'); const Systrace = require('../../Performance/Systrace'); const invariant = require('invariant'); @@ -36,14 +35,6 @@ export type JSTimerType = const FRAME_DURATION = 1000 / 60; const IDLE_CALLBACK_FRAME_DEADLINE = 1; -const MAX_TIMER_DURATION_MS = 60 * 1000; -const IS_ANDROID = Platform.OS === 'android'; -const ANDROID_LONG_TIMER_MESSAGE = - 'Setting a timer for a long period of time, i.e. multiple minutes, is a ' + - 'performance and correctness issue on Android as it keeps the timer ' + - 'module awake, and timers can only be called when the app is in the foreground. ' + - 'See https://github.com/facebook/react-native/issues/12981 for more info.'; - // Parallel arrays const callbacks: Array = []; const types: Array = []; @@ -218,15 +209,6 @@ const JSTimers = { * @param {number} duration Number of milliseconds. */ setTimeout: function(func: Function, duration: number, ...args: any): number { - if (__DEV__ && IS_ANDROID && duration > MAX_TIMER_DURATION_MS) { - console.warn( - ANDROID_LONG_TIMER_MESSAGE + - '\n' + - '(Saw setTimeout with duration ' + - duration + - 'ms)', - ); - } const id = _allocateCallback( () => func.apply(undefined, args), 'setTimeout', @@ -244,15 +226,6 @@ const JSTimers = { duration: number, ...args: any ): number { - if (__DEV__ && IS_ANDROID && duration > MAX_TIMER_DURATION_MS) { - console.warn( - ANDROID_LONG_TIMER_MESSAGE + - '\n' + - '(Saw setInterval with duration ' + - duration + - 'ms)', - ); - } const id = _allocateCallback( () => func.apply(undefined, args), 'setInterval',