-
Notifications
You must be signed in to change notification settings - Fork 898
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Setting a timer for a long period of time, i.e. multiple minutes #97
Comments
Hey there! I couldn't figure out what this issue is about, so I've labeled it for a human to triage. Hang tight. |
Hmmm this issue does not seem to follow the issue template. Make sure you provide all the required information. |
I assume you are including real-time database in your code? |
Yeah I'm using |
@bojeil-google Could you please update here when this has been resolved? Thank you! |
|
I wonder, this issue show up only in Android, and maybe it's caused by using react-navigator, I say this, because once I all repeat from tutorial and tutor doesn't get this error and only difference between our works it's I use react-navigator instead react-native-router-flux and I work with Android instead IOS |
Maybe, we could throw this code below in to the project, and reset all
|
When will This issue be resolved? |
There are bunch of high priority features and bug fixes in the pipeline. We'll switch to this issue immediately after. It's been labeled as a P3 issue which is appropriate for its severity. |
Hello guys, any update on this issue please? I have not been able to use Firebase on Android because of it. |
Using the native sdk instead of the js/web sdk fixes the problem. https://github.com/invertase/react-native-firebase It involves a lot more configuration and it won’t work with Expo tho. |
My understanding is that this is not a blocking issue and can be suppressed. |
Ok, I tried testing this issue with react native 0.48.4 and firebase 4.6.2 using an Android emulator (API 25) and I was not able to replicate this. I am not getting the warning at all. |
I am still getting this warning |
Can you provide more detailed information about your environment to facilitate replication? |
I use Expo and get this error. Perhaps it is specific to Expo, which may be
why you did not get an error on your emulator.
…On Tue, Nov 28, 2017 at 2:38 AM, bojeil-google ***@***.***> wrote:
Can you provide more detailed information about your environment to
facilitate replication?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#97 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AdTknxE4yq8eD5wXOenm_14wg7o8KCJ1ks5s67h7gaJpZM4OYphr>
.
|
I also used expo version |
@brunolemos, I totally agree with you. But it definitely is nice to be able to hide the warnings while waiting for a proper fix. |
There is no fix yet? So many people have this problem! |
I have the exact same problem as @colinwong As it is right now firebase and expo seem to be unusable together. |
@colinwong @LukasNavickas @Renji3 This problem is "normal" and has nothing to do with the timer error. Firestore is not supported by React Native (#283). The only solutions : Using Firebase Realtime Database or https://github.com/invertase/react-native-firebase (which is not compatible with Expo). |
Hey folks, figured I'd chime in here. Ultimately the fix needs to be made on the There is a workaround for the warning that you are seeing that @bojeil-google mentioned that we could implement. i.e.
Using multi-step short duration So the net of all that is: This bug can't be fixed here we can only work around the error there are workarounds available (see https://stackoverflow.com/questions/44603362/setting-a-timer-for-a-long-period-of-time-i-e-multiple-minutes) that disable the warning. Doing the work to disable the warning in our code, doesn't help the issue (beyond disabling the warning), and adds additional SDK code/weight that is completely unnecessary. I'd recommend chiming in on the issue mentioned above (i.e. facebook/react-native#12981) if you aren't comfortable w/ the workaround provided. |
Maybe the best way to go through this problem is by changing JSTimers.js until they really fix it |
facebook/react-native#12981 (comment) has a cleaner temporary fix for this. |
We really need a solution for this.
|
Same problem here. I am using 30.0.1 and firebase 5.5.2. |
Work around issue with yellow warning 'Setting a timer' . copy & import following file (as fast as you can ;-)) import {Platform, InteractionManager} from 'react-native';
const _setTimeout = global.setTimeout;
const _clearTimeout = global.clearTimeout;
const MAX_TIMER_DURATION_MS = 60 * 1000;
if (Platform.OS === 'android') {
// Work around issue `Setting a timer for long time`
// see: https://github.com/firebase/firebase-js-sdk/issues/97
const timerFix = {};
const runTask = (id, fn, ttl, args) => {
const waitingTime = ttl - Date.now();
if (waitingTime <= 1) {
InteractionManager.runAfterInteractions(() => {
if (!timerFix[id]) {
return;
}
delete timerFix[id];
fn(...args);
});
return;
}
const afterTime = Math.min(waitingTime, MAX_TIMER_DURATION_MS);
timerFix[id] = _setTimeout(() => runTask(id, fn, ttl, args), afterTime);
};
global.setTimeout = (fn, time, ...args) => {
if (MAX_TIMER_DURATION_MS < time) {
const ttl = Date.now() + time;
const id = '_lt_' + Object.keys(timerFix).length;
runTask(id, fn, ttl, args);
return id;
}
return _setTimeout(fn, time, ...args);
};
global.clearTimeout = id => {
if (typeof id === 'string' && id.startsWith('_lt_')) {
_clearTimeout(timerFix[id]);
delete timerFix[id];
return;
}
_clearTimeout(id);
};
} |
still getting this error :/ apps getting crashed due to this..! |
Did you add 'fix code' before first setTimeout was used? |
This worked for me ... pretty solution ! |
The problem persists, unfortunately... |
it seems to work but I had to replace startWith by startsWith thanks |
this warning from socket firebase add that code to the App file to get rid of that warning |
Is this getting fixed any time soon? I have the same issue and I see it has been here since 2017. I'm using Expo SDK v32 and I'm not using the realtime database but rather the Firebase Firestore. |
My friends I had the same error just 20 minutes ago and I figured out the cause of the error, I had to define a value for the iterations param in the Animated.loop function:
By default the value of the "iterations" param is -1, meaning the animation will run with infinite loops, but this feature is implemented by using a setTimeOut function with a big number of seconds in order to run the animation 'infinite' times. Problem Solved |
Could yo explain a bit more about your solution? I actually never declare an animation variable in my app. Let's just hope a proper bug fix comes. |
Has anyone managed to find a fix for this yet? It doesn't prevent development or stop the app working but it's a bit of a pain and I don't like the idea of just supressing an underlying issue, I will for now though. |
To sort this out you need to hard code the value, increase the value of the variable MAX_TIMER_DURATION_MS. Here are the steps: Go to node_modules/react-native/Libraries/Core/Timer/JSTimers.js Look for the variable MAX_TIMER_DURATION_MS Change 60 * 1000 to 10000 * 1000 Save the changes and re-build your app. This worked for me. |
I want to use firebase auth with react native for Login and Signup but I got a yellow error:
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 (facebook/react-native#12981) for more info. (Saw setTimeout with duration 111862ms)
How Can I Fix That?
I don't want to ignore that, I want to understand this error and solve that with the best and Standard way.
And This is my Code:
I Asked From Stackoverflow too, Link
The text was updated successfully, but these errors were encountered: