Skip to content

Commit 480dabd

Browse files
yungstersfacebook-github-bot
authored andcommitted
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
1 parent 9be3356 commit 480dabd

File tree

1 file changed

+0
-27
lines changed

1 file changed

+0
-27
lines changed

Libraries/Core/Timers/JSTimers.js

-27
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
'use strict';
1212

1313
const BatchedBridge = require('../../BatchedBridge/BatchedBridge');
14-
const Platform = require('../../Utilities/Platform');
1514
const Systrace = require('../../Performance/Systrace');
1615

1716
const invariant = require('invariant');
@@ -36,14 +35,6 @@ export type JSTimerType =
3635
const FRAME_DURATION = 1000 / 60;
3736
const IDLE_CALLBACK_FRAME_DEADLINE = 1;
3837

39-
const MAX_TIMER_DURATION_MS = 60 * 1000;
40-
const IS_ANDROID = Platform.OS === 'android';
41-
const ANDROID_LONG_TIMER_MESSAGE =
42-
'Setting a timer for a long period of time, i.e. multiple minutes, is a ' +
43-
'performance and correctness issue on Android as it keeps the timer ' +
44-
'module awake, and timers can only be called when the app is in the foreground. ' +
45-
'See https://github.com/facebook/react-native/issues/12981 for more info.';
46-
4738
// Parallel arrays
4839
const callbacks: Array<?Function> = [];
4940
const types: Array<?JSTimerType> = [];
@@ -218,15 +209,6 @@ const JSTimers = {
218209
* @param {number} duration Number of milliseconds.
219210
*/
220211
setTimeout: function(func: Function, duration: number, ...args: any): number {
221-
if (__DEV__ && IS_ANDROID && duration > MAX_TIMER_DURATION_MS) {
222-
console.warn(
223-
ANDROID_LONG_TIMER_MESSAGE +
224-
'\n' +
225-
'(Saw setTimeout with duration ' +
226-
duration +
227-
'ms)',
228-
);
229-
}
230212
const id = _allocateCallback(
231213
() => func.apply(undefined, args),
232214
'setTimeout',
@@ -244,15 +226,6 @@ const JSTimers = {
244226
duration: number,
245227
...args: any
246228
): number {
247-
if (__DEV__ && IS_ANDROID && duration > MAX_TIMER_DURATION_MS) {
248-
console.warn(
249-
ANDROID_LONG_TIMER_MESSAGE +
250-
'\n' +
251-
'(Saw setInterval with duration ' +
252-
duration +
253-
'ms)',
254-
);
255-
}
256229
const id = _allocateCallback(
257230
() => func.apply(undefined, args),
258231
'setInterval',

0 commit comments

Comments
 (0)