Context
I am using shadow-cljs in the clojurescript (react-native) project.
And for triggering UI rerender I am using :before-load-async
and :afterload
lifecycle hooks. The reagent atom is used as the key for screens and in :afterload
event this key is bumped to trigger re-rendering.
I also added a locking mechanism to make sure two rerendering don't get triggered at once.
Problem
As several screens and components are getting rerendered, it sometimes takes some time (2-3 sec). If in the meantime I modify any related file and trigger a rebuild, the app crashes with Fatal signal 6 (SIGABRT), code -6 (SI_TKILL) in tid 24537
.
(Note: Issue don't happen always, some time needs to quickly edit and save the file 7- 8 times, for timing the collision)
Things I tried
I tried adding a significant delay(20 sec) for blocking a call to :afterload
to make sure we are not bumping the reagent atom before the first rerender completes.
Possible Cause
While we are forcing rerender to old hot reloaded code, code changes due to another build and breaks forced render
Possible Solution
I can control the UI part with the help of locking and async hooks but I am not sure how can I delay auto hot reloading.
Either, there should be a config parameter to add delays between autobuilds or I should able to stop auto builds in :before-load-async
and resume in the :afterload
hook. But as shadow.cljs.devtools.api
is a clj file I am not able to call (shadow.cljs.devtools.api/watch-set-autobuild! :app false)
in cljs
Related code: https://github.com/Parveshdhull/status-mobile/commit/2c505fd01f4d5b11dc9509f9bb18fabf355ed222
Crash log: https://drive.google.com/file/d/1zhymiED1o7rpTsmpwbwQ_xOVPRMu64Ug/view?usp=sharing