The app freezes a few seconds after hot reload (shadow-cljs) on android, but not on ios. Anyone have even the faintest idea what could be going on, or what I can try do to isolate the problem?
Now it doesn’t freeze on hot-reload.
Jokes aside. I’ve narrowed it down to the require of our re-frame handlers namespace. But we make A LOT of requires there, and there are A LOT of handlers. I don’t think I will have all handlers in the same ns with the next app I build.
I’m goin’ in again now. Cheers!
I’m starting to suspect a circular dependency. That is just a hunch based on nothing, but anyway. I now have like a long thin drinking straw of namespaces requiring just one namespace 15 levels deep, I wonder how deep I will need to go before I hit bed rock. 😃
shadow-cljs won't compile circular dependencies. you'll get an error if you have one.
Based on nothing. 😎 I have a feeling I will figure this out. Which is a great improvement from lately.
It doesn’t freeze if I reload using the REPL.
The way it freezes is that I can still scroll the screens, but nothing else works. Touchables do not give any feedback, for instance.
Debugger or no debugger, doesn’t make a difference.
does it freeze if your :dev/after-load
does nothing? or does it only freeze when that does stuff (eg. re-render)?
might be something in your code causing an infinite loop or so?
Now tried. It freezes also when I have
(defn render
{:dev/after-load true}
[])
And even when I do stuff in that function. I can redefine things in the app and evaluate (render)
to see the new definitions take effect. And then it does not freeze up.
do you have code that runs directly when loading the namespaces?
I don’t think so…
Don’t know if this is a clue, but at the same time this freeze happens I lose the REPL and also see this in the debugger: [React DevTools] Connection to RN closed
Maybe that’s consistent with the infinite loop hypothesis…
How could it look like, running code directly when loading the namespaces? Top level evaluations?
things that are not in a function I think
Well, I get the freeze even if shadow only compiles stuff that does only have def
and defn
things, and rich comments, top level.
Assuming that nothing is re-loaded that is not re-compiled.
btw, @thomas it is the same kind of android-only freeze that I had in the project’s release builds before upgrading React Native and React Navigation. Now the release builds behave, but my android dev workflow is so broken…
hmm weird stuff going on here by the sounds of it.
I have myself to blame a bit since I have avoided the Android emulator and mostly used iOS so didn’t notice when this weirdness started to happen.
I would try commenting out everything and loading just one view with one button that shows an alert, for example. Keep tapping that. Does it freeze then? If it does not freeze, then comment back in component by component to see when the problem appears.
Another random idea: does your Android app use Hermes by any chance? I haven’t used it, but David Nolen recently said that it caused weird problem for them.
I had never heard of Hermes before reading that comment from Nolen. It’s disabled in build.gradle at least.
Will probably do the commenting out everything thing. I’m totally out of any other idea.
@pez you haven't mentioned your Android setup - what version of Android etc.
Right. I should mention those things of course. I get this behaviour in the Emulator with some modern versions of Android as well as on my physical testing device which is a Samsung S5, with Android 6.0.1. A colleague has a very new phone which experienced the same “type” of freeze in a release build. I had the same on my test device. That freeze stopped to happen when I commented out a couple of SmoothenNextTransition uses, and also stops happening on a branch where I have those uses active, but have upgraded to latest RN and React Navigation 4. I mention this because I suspect that this dev-reload thing is the same problem, only triggered from a different path. Also, sometimes instead of this freeze, the app is just killed by the OS.