Debugging the AppState Manager: A Stream-of-Consciousness Exploration
TL;DR
- App state transition manager instantiation challenges with user sessions.
- Addressing possible race conditions and stale references when users sign out.
- Confirming MMKV storage persistence across user transitions and app lifecycle events.
- Facing a tricky bug that defies consistent reproduction.
Today was one of those days where my brain felt like it was playing ping-pong inside my head. I couldn’t move the app state manager init into app.tsx without worrying about testing complexities that might crop up. Hmm… I figured that if I initialized on every render, I might have a problem later with referencing scopes differently. Maybe I’m over-engineering this?
Moving onto more tangible issues, I fixed device storage issues by updating types after MMKV library upgrades. Small victory! Auth context? That was another rabbit hole of ensuring logic returns behave as expected during sign-out transitions.
A bug haunted me, manifesting only once, inexplicably, after user switches. Initially, I suspected that signing out might dereference the local storage, impacting the stored timestamp access needed in app inactive states. My conclusion: nope, not the problem. The app creates its own storage container, separate from user scopes.
Next stop on this journey: does the useAppStateTransition hook get consumed properly? Well, seems no matter whether the user has a vision or not, transitions are triggered reliably as always.
Testing if storage persists, just set some MMKV values and voila, persisted across reloads and even closing the app. Can’t argue with concrete proof there. But does the app state change handler get registered as it should? Apparently, yes, consistently.
In all honesty, it’s challenging to reproduce the very issue that sparked this debugging odyssey. My setup doesn’t seem to show signs of breaking, neither with switching users, nor closing and re-opening the app.
At this point, it’s gone back into my backlog of unresolved mysteries. Sometimes bugs are just that slippery. Moving on for now, with a face of steam ☁️ that says it all. Hyper focused on what I can tackle next!
ryer.io