mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
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
This commit is contained in:
committed by
Facebook GitHub Bot
parent
9be3356e02
commit
480dabd665
@@ -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<?Function> = [];
|
||||
const types: Array<?JSTimerType> = [];
|
||||
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user