react-native-threads
react-native-threads copied to clipboard
iOS Error
Android seems to work, but when I run iOS, I see:
2017-10-06 15:21:28.391 [fatal][tid:com.facebook.react.WebSocketExecutor] Runtime is not ready for debugging. Make sure Packager server is running.
I'm not manually running a second packager, do I need to?
You don't need to run a second packager, I also see this error occasionally when the app tries to load the worker before packager has finished bundling it. When I get this error I look at the packager output in the terminal, wait until the progress bar finishes and then refresh my app.
Thanks for your reply. I can check again next week, but it didn't seem to be an issue with the packager not being done yet, as it happens consistently, and I'm doing fairly extreme things to delay the startup (like a 15 second setTimeout to initialize the worker on launch). Can you think of anything else it might be? Or even a direction for me to look in? I'm familiar with debugging in xcode/objc and chrome, but unfamiliar with the RN native code base. I'm happy to root around if you give me a direction or things to look for.
Also, thank you for making this ❤️
Thanks @garrettm! I looked into this a bit more, and I'm able to consistently reproduce that error on iOS when remote debugging is enabled.
Interestingly, the error persists even after turning off remote debugging until I restart the app. Even reloading doesn't get rid of the error, I have kill the app by double pressing home button (pressing Command + Shift + H twice on the simulator) and swiping the app away.
When you see that error again, can you try dismissing the red screen, opening the dev menu, disabling remote debugging, restarting the app, and seeing if that resolves the issue? You might even need to uninstall and reinstall the app after disabling remote debugging.
I haven't been able to get remote debugging working with threads, so I use Reactotron for my debugging needs as mentioned in the README. It's definitely not ideal though, I would like to find some way to customize the dev menu to allow opening a remote debugger for both the main react native js process as well as any 'thread' js processes. I just haven't had the time yet to research how that would work.
@Traviskn I've tried what you said. With the debugger turned off, it seems like I can use the app just fine until I call new Worker
(where Worker = RNThread.Thread). Then the app becomes completely unresponsive, though the worker seems to be able to keep going (it keeps fetching images, and the UI updates with them). Once the app becomes unresponsive, I need to completely kill and restart the app (normal RN debug menu -> reload does not work).
Trying it again with the debugger on, the behavior seems roughly the same, except for what happens when I create a new RNThread is different. With the debugger on, I see the red screen, instead of the app becoming completely unresponsive. But otherwise, the symptoms are the same, I cannot use the app until I completely force-kill it and relaunch it.
I am using react-native 0.48.1, FYI.
Is there any way I could just make the worker threads not participate in debugging? I'd be fine with not being able to debug them, (other than posted log messages) if it meant that I could use them with the normal dev setup.
@garrettm Dang, I'm not really sure what's going on then! I'm not sure I understand how the app is able to update the UI with images if it is also unresponsive. Would you be able to share any code samples with me that reproduce the issue for you? I'm also curious if you run into the same issues running the example app on iOS.
I personally am not able to successfully run the remote debugger with threads running, I have to use another tool like Reactotron. I would love to find some way to get the normal remote debugger working better, but for now my recommendation is to not turn on the remote debugger while running threads.
@Traviskn is there any way I could tweak this package to opt out of debugging completely for threads? I'm assuming that would help the issue I'm seeing, and it would let me use the package without having to significantly add to my debugging setup.
After looking around, it looks like this fork of react-native-workers has found a way to improve the iOS debugging situation: https://github.com/jamesreggio/react-native-workers/commit/d3644aa322609068d9f62e9fc325a4d1f35301f3
I'll keep looking into this and see if that strategy will also work here, I would definitely love to get the built-in remote debugger working
@Traviskn is there something I can help with? I am eager to spend some time to help make this work more cleanly, if you can tell me what you could use help with.
For the record, this is with react-native 0.48.1 and react-native-threads 0.0.4
If these aren't expected to be compatible, I can upgrade one or both and try again.
I am trying the react-native-workers package you linked, not having much more luck. As soon as I try to use the bridge, the app either red-boxes (with debugging enabled) or locks up (with debugging disabled) and then red-boxes shortly after that.
@garrettm sorry to hear that, I would definitely recommend using the latest release of react-native-threads as we're working out the bugs.
Unfortunately right now running the remote debugger will cause crashes and I still need to research how to either stop the debugger from launching for the background thread, or get the debugger to support threads. I don't really know much more than you do at this point about how to do that.
For now my recommendation is to not run the remote debugger and instead use tools like Reactotron. Check out the example app to see the recommended debugging workflow.
I'll keep looking into this and keep you updated when I figure out how to make the remote debugger behave better.
@Traviskn thanks for your help, I'll probably poke around on working that out if I get a chance.
@Traviskn FYI I have forked this repo: https://github.com/jamesreggio/react-native-workers
And disabled remote debugging for threads, and things seem to work on RN 0.50.1. Here's my fork: https://github.com/garrettm/react-native-workers
(I used your SimpleExample for testing)
Awesome, thanks for the heads up! I'll definitely check that out
@Traviskn I have the same problem on RN 0.51.0. You could not solve it?
@VertaZoom Unfortunately you cannot have the remote debugger turned on while using react-native-threads. If you have turned on the remote debugger and run into this problem you will need to disable remote debugging from the development menu, and then you'll need to stop and restart the app by double pressing the home button and swiping it away. I currently recommend using a debugging tool like reactotron to work around this issue. See the example app in this repo for a reference on how to set that up, it is pretty simple to configure.
I'm hoping to find time soon to see if I can get better support for the built-in remote debugger working
Hi @Traviskn, were you able to find any solution for this? I am still able to reproduce the same issue on RN 0.55.3 even with remote debugging disabled.
Are there any news on this? This is still an issue for me
Aw too bad. It's the only thing stopping me from using this. I use remote debugging all the time, and tbh, I don't like Reactotron that much :(
Same here
This is an awesome project. I can live without debugging the worker threads, but the lack of support for running the debugger on the main thread is a bit of a deal breaker.
Does anyone have a solution?