-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
setTimeout and setInterval don't fire on Android RN 0.31 when attached to Chrome Debugger #9436
Comments
Facing the same issue when I connect to chrome debugger. |
Is this related to #9319? |
what about #4470 , seems it's not a regression, but a knowing bug for quite a long time |
Having same issue RN 31 while debugging with Chrome only |
Ok, successfully reproduced this with a new project. Steps to reproduce,
react-native init TimerBug
cd TimerBug
react-native run-android
setTimeout(() => console.warn('fired'), 10); // duration can be anything See YellowBox coming up
It never fires cc @bestander |
This might be related to the new bridge on Android and #9319 ( I'll ping @cjhopman and @mhorowitz on fb@work messenger. |
I found the problem and a fix should make it to the next release. We we're accidentally dropping all native calls made during loading of the JS bundle which causes the thing that was driving the queue to not be called. |
@lexs We can probably cherry-pick this to current release? |
it still exists in v0.33.0-rc.0 |
Yes, it has been cherry-picked but a new release was not triggered. |
my project depends on a lib that base on android RN0.31 .. i had change the line of code .. but i dont know how to rebuild react-native package to get it work... i had try : npm rebuild & react-native upgrade ... but not not work |
@Hanruis, here are some instructions for Android on how to configure your app to use a custom version of React Native: https://facebook.github.io/react-native/docs/android-building-from-source.html |
@rigdern thx. i know it....but is there any easier way possible to just rebuild the react-native npm package and get it work? |
@Hanruis, the npm package comes with prebuilt jars of React Native, you need full source code to produce them, @rigdern's solution is the correct. A quick recap:
|
@bestander get, thx ~~~ |
For the people who are still facing this issue ! which is the case for us on RN 0.44.0 on Android : We found indeed that the problem was related to the device time not being exactly as the time on the chrome remote debugger machine. This is due to the React Native javascript setTimeout function calling the native Timing.createTimer method with a Date.now() parameter which is not the same as the native side's time when in remote js debug mode (where the javascript execution environment is the chrome browser or whatever debugger you're using) as you can see in JSTimers.js#L93. So, the solution for us was 1 of the following :
We chose the second solution as the first one wasn't suited for our needs so we created a package called React Native Timer Native (I know, i'm not so good when it comes to naming things ^^') which is a fork of React Native Timer. What it does --as a stupid hack-- is simply call a native method (when in dev mode) with the current javascript timestamp, then the native method gets its current timestamp using The device time must be in the future compared to the remote debugging machine time otherwise it doesn't work properly It does get the timeouts executed with a decent precision (still need to substract the time that the bridge takes to call the native method so any inputs are welcome ;) ). |
This is still an issue with RN 0.45.1 (you can check with @satya164 code) |
I have the same issue on the iOS platfom with RN 0.45.1. I first discovered it through the redux-saga library. One of the delays wasn't working with the remote debugger enabled but was actually working correctly without the remote debugger. I then tried with a simple |
We have the same issue when running RN 0.45.1 in iOS simulator attached to Chrome debugger. Timers don't fire at all. But they start to fire when we detach JS debugger. iOS simulator automatically synchronizes time with the host machine, and, as far as I know, there is no way to adjust it manually using the UI. |
Seems like timers in general are affected ( |
same issues when running RN 0.46.1 when i debug my app with google chrome debugger. |
@adamnator92 this is fixed in 0.47: #14681 (comment) |
@cbrevik thank you so much for that :) |
@cbrevik I still experience significant delays while using setTimeout on Android with Chrome debugger. No issues when the debugger is detached. RN 0.47.2 |
@mandriv The fix in 0.47 which I referenced was iOS-specific. So problems with Android is probably caused by something else. |
I'm having the same issue, with iOS and 0.47. This should be at least mentioned in the docs, probably here. This is a hard bug to find and I can imagine it has caused a good amount of developer hours lost. Simple solution: ⌘D or equivalent, Stop Remote Debugging. |
Same issue here with iOS simulator & 0.47. Please reopen the issue as this is not fixed. |
Same issue |
I set the device time exactly with the debugger time and it works ;) |
For whom guess how to update device time, use adb from a terminal: |
I had to also fully restart my Android Emulator after running the |
Same issue in rn 0.52.1 |
Still getting this in 0.53.3. |
RN 0.53 Same issue |
RN 0.54 ; getting this issue as well. |
RN 0.53 android - I was able to resolve following the trick here |
Experiencing this issue on v0.54.2. Any fixes? |
Same here, v0.54.0 |
Got the same issue as well, just starting into ReactNative and discovering things like makes me cautious moving forward, this seems pretty basic. |
Need to sync debugging computer with device. Execute on your computer:
|
setTimeout(() => console.log("#############", 1000);
setInterval(() => console.log("#############", 1000);
NetInfo.fetch().done(v => console.log(v));
not fire on android RN 0.31 but fire on RN 0.30
Env: Mac os 11.6
The text was updated successfully, but these errors were encountered: