Fork me on GitHub
#cljsrn
<
2021-06-23
>
pez11:06:41

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?

pez11:06:18

It doesn’t freeze if I reload using the REPL.

pez11:06:55

The way it freezes is that I can still scroll the screens, but nothing else works. Touchables do not give any feedback, for instance.

pez11:06:13

Debugger or no debugger, doesn’t make a difference.

thheller11:06:58

does it freeze if your :dev/after-load does nothing? or does it only freeze when that does stuff (eg. re-render)?

thheller11:06:09

might be something in your code causing an infinite loop or so?

pez12:06:24

Now tried. It freezes also when I have

(defn render
  {:dev/after-load true}
  [])

pez12:06:56

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.

thheller12:06:50

do you have code that runs directly when loading the namespaces?

pez12:06:35

I don’t think so…

pez12:06:47

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

pez12:06:12

Maybe that’s consistent with the infinite loop hypothesis…

pez12:06:51

How could it look like, running code directly when loading the namespaces? Top level evaluations?

thomas12:06:35

things that are not in a function I think

pez13:06:33

Well, I get the freeze even if shadow only compiles stuff that does only have def and defn things, and rich comments, top level.

pez13:06:15

Assuming that nothing is re-loaded that is not re-compiled.

pez13:06:34

btw, @U052852ES 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…

thomas13:06:02

hmm weird stuff going on here by the sounds of it.

pez13:06:14

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.

raspasov14:06:30

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.

raspasov14:06:26

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.

pez14:06:05

I had never heard of Hermes before reading that comment from Nolen. It’s disabled in build.gradle at least.

pez14:06:38

Will probably do the commenting out everything thing. I’m totally out of any other idea.

👌 2
pez11:06:03

Now it doesn’t freeze on hot-reload.

pez11:06:33

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.

pez11:06:57

I’m goin’ in again now. Cheers!

pez13:06:02

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. 😃

thheller13:06:05

shadow-cljs won't compile circular dependencies. you'll get an error if you have one.

pez13:06:57

Based on nothing. 😎 I have a feeling I will figure this out. Which is a great improvement from lately.

👍 2
dnolen16:06:40

@pez you haven't mentioned your Android setup - what version of Android etc.

pez16:06:12

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.