-
-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug] App crashing when using useMMKVStorage hook #363
Comments
@ammarahm-ed pinging only because this is a pretty intense issue |
Facing same error on a small number of devices on iOS, I just upgraded to the new version. it seems to be related to specific storages not all of the storages on my app are affected. Version: |
I will look into this, would greatly appreciate if someone can provide crash logs from the release build |
I don't know if this is helpful, this is the log from firebase crashlytics on user device.
|
Thanks @mmmoussa I am looking into the issue |
Hey everyone, can you try the latest version v0.11.0 and see whether it fixes those crashes. I was unable to reproduce this locally btw but I have made a fix based on some assumptions. |
@ammarahm-ed the app doesn't build on iOS with the latest version and the old architecture, due to the following issue: |
Hey @mmmoussa try v0.11.0. It should probably fix the build error. |
It builds fine on RN 0.76. Let me try on an older version. |
Hey @mmmoussa Just released v0.11.2, can you try now. Make sure to delete Pods & build folders inside your project's ios folder. |
Build is now working on RN 0.75.4. Will circle back regarding the actual issue being observed. |
Issue is not resolved by v0.11.2 |
Can you provide any native crash logs? You can find any native crash logs related to MMKV from Can you try initializing your MMKV with Do this for MMKV instance that is not used by Also can you confirm if the issue is only happening to people who are upgrading the app. The new installs work as expected? |
Hey @kashmiry @CoryWritesCode anyone of you guys able to reproduce this in release or debug locally would be really helpful in fixing this. Any steps or specifics. |
@ammarahm-ed I upgraded from react-native 0.73.6 to 0.76.1 with new arch. Using v0.11.2 .This issue is IOS only android works fine. XCODE CONSOLE Bridgeless mode is enabled
[I] <MMKV.cpp:166::initialize> version v1.3.9, page size 4096, arch x86_64
[I] <MMKV.cpp:218::initializeMMKV> Apple Device: 0, version: 86, mlock enabled: 0
[I] <MMKV.cpp:225::initializeMMKV> root dir: /Users/apple/Library/Developer/CoreSimulator/Devices/1E1E4708-1D21-4F0F-BF41-90E38BC4BB35/data/Containers/Data/Application/40124B1F-023E-4A80-A609-0FA76D6B42EE/Library/mmkv
[I] <MemoryFile.cpp:98::open> open fd[0x17], /Users/apple/Library/Developer/CoreSimulator/Devices/1E1E4708-1D21-4F0F-BF41-90E38BC4BB35/data/Containers/Data/Application/40124B1F-023E-4A80-A609-0FA76D6B42EE/Library/mmkv/mmkvIdStore
[I] <MemoryFile.cpp:203::mmap> mmap to address [0x104bfa000], oldPtr [0x0], [/Users/apple/Library/Developer/CoreSimulator/Devices/1E1E4708-1D21-4F0F-BF41-90E38BC4BB35/data/Containers/Data/Application/40124B1F-023E-4A80-A609-0FA76D6B42EE/Library/mmkv/mmkvIdStore]
[I] <MemoryFile_OSX.cpp:35::tryResetFileProtection> protection on [/Users/apple/Library/Developer/CoreSimulator/Devices/1E1E4708-1D21-4F0F-BF41-90E38BC4BB35/data/Containers/Data/Application/40124B1F-023E-4A80-A609-0FA76D6B42EE/Library/mmkv/mmkvIdStore] is (null)
[I] <MemoryFile.cpp:98::open> open fd[0x18], /Users/apple/Library/Developer/CoreSimulator/Devices/1E1E4708-1D21-4F0F-BF41-90E38BC4BB35/data/Containers/Data/Application/40124B1F-023E-4A80-A609-0FA76D6B42EE/Library/mmkv/mmkvIdStore.crc
[I] <MemoryFile.cpp:203::mmap> mmap to address [0x1059d3000], oldPtr [0x0], [/Users/apple/Library/Developer/CoreSimulator/Devices/1E1E4708-1D21-4F0F-BF41-90E38BC4BB35/data/Containers/Data/Application/40124B1F-023E-4A80-A609-0FA76D6B42EE/Library/mmkv/mmkvIdStore.crc]
[I] <MemoryFile_OSX.cpp:35::tryResetFileProtection> protection on [/Users/apple/Library/Developer/CoreSimulator/Devices/1E1E4708-1D21-4F0F-BF41-90E38BC4BB35/data/Containers/Data/Application/40124B1F-023E-4A80-A609-0FA76D6B42EE/Library/mmkv/mmkvIdStore.crc] is (null)
[I] <MMKV_IO.cpp:84::loadFromFile> loading [mmkvIdStore] with 341 actual size, file size 4096, InterProcess 0, meta info version:3
[I] <MMKV_IO.cpp:89::loadFromFile> loading [mmkvIdStore] with crc 1898287713 sequence 1 version 3
[I] <MMKV_IO.cpp:133::loadFromFile> loaded [mmkvIdStore] with 2 key-values
[I] <MemoryFile.cpp:98::open> open fd[0x19], /Users/apple/Library/Developer/CoreSimulator/Devices/1E1E4708-1D21-4F0F-BF41-90E38BC4BB35/data/Containers/Data/Application/40124B1F-023E-4A80-A609-0FA76D6B42EE/Library/mmkv/default
[I] <MemoryFile.cpp:203::mmap> mmap to address [0x116100000], oldPtr [0x0], [/Users/apple/Library/Developer/CoreSimulator/Devices/1E1E4708-1D21-4F0F-BF41-90E38BC4BB35/data/Containers/Data/Application/40124B1F-023E-4A80-A609-0FA76D6B42EE/Library/mmkv/default]
[I] <MemoryFile_OSX.cpp:35::tryResetFileProtection> protection on [/Users/apple/Library/Developer/CoreSimulator/Devices/1E1E4708-1D21-4F0F-BF41-90E38BC4BB35/data/Containers/Data/Application/40124B1F-023E-4A80-A609-0FA76D6B42EE/Library/mmkv/default] is (null)
[I] <MemoryFile.cpp:98::open> open fd[0x1a], /Users/apple/Library/Developer/CoreSimulator/Devices/1E1E4708-1D21-4F0F-BF41-90E38BC4BB35/data/Containers/Data/Application/40124B1F-023E-4A80-A609-0FA76D6B42EE/Library/mmkv/default.crc
[I] <MemoryFile.cpp:203::mmap> mmap to address [0x1059d4000], oldPtr [0x0], [/Users/apple/Library/Developer/CoreSimulator/Devices/1E1E4708-1D21-4F0F-BF41-90E38BC4BB35/data/Containers/Data/Application/40124B1F-023E-4A80-A609-0FA76D6B42EE/Library/mmkv/default.crc]
[I] <MemoryFile_OSX.cpp:35::tryResetFileProtection> protection on [/Users/apple/Library/Developer/CoreSimulator/Devices/1E1E4708-1D21-4F0F-BF41-90E38BC4BB35/data/Containers/Data/Application/40124B1F-023E-4A80-A609-0FA76D6B42EE/Library/mmkv/default.crc] is (null)
[I] <MMKV_IO.cpp:84::loadFromFile> loading [default] with 300201 actual size, file size 524288, InterProcess 0, meta info version:3
[I] <MMKV_IO.cpp:89::loadFromFile> loading [default] with crc 173294742 sequence 318 version 3
[I] <MMKV_IO.cpp:133::loadFromFile> loaded [default] with 15 key-values
+[RNFBAppModule getCustomDomain:] [Line 239] authDomains: (null)
+[RNFBSharedUtils getConfigBooleanValue:key:defaultValue:] [Line 162] RNFBCrashlyticsInit crashlytics_debug_enabled via RNFBMeta: 0
+[RNFBSharedUtils getConfigBooleanValue:key:defaultValue:] [Line 165] RNFBCrashlyticsInit crashlytics_debug_enabled final value: 0
+[RNFBCrashlyticsInitProvider isCrashlyticsCollectionEnabled] [Line 67] RNFBCrashlyticsInit isCrashlyticsCollectionEnabled after checking crashlytics_debug_enabled: 0
+[RNFBSharedUtils getConfigBooleanValue:key:defaultValue:] [Line 162] RNFBCrashlyticsInit crashlytics_is_error_generation_on_js_crash_enabled via RNFBMeta: 1
+[RNFBSharedUtils getConfigBooleanValue:key:defaultValue:] [Line 165] RNFBCrashlyticsInit crashlytics_is_error_generation_on_js_crash_enabled final value: 1
+[RNFBSharedUtils getConfigBooleanValue:key:defaultValue:] [Line 162] RNFBCrashlyticsInit crashlytics_javascript_exception_handler_chaining_enabled via RNFBMeta: 1
+[RNFBSharedUtils getConfigBooleanValue:key:defaultValue:] [Line 165] RNFBCrashlyticsInit crashlytics_javascript_exception_handler_chaining_enabled final value: 1
Crashlytics - WARNING: Debugger detected. Crashlytics will not receive crash reports.
Unbalanced calls start/end for tag 20
Unbalanced calls start/end for tag 19
Running "dat.app" with {"rootTag":1,"initialProps":{"concurrentRoot":true},"fabric":true}
Warning: Error: Exception in HostFunction: <unknown>
This error is located at:
in AppServicesStoreProvider (created by ApplicationContainer)
in RouterWrapper (created by ApplicationContainer)
in ScreenContextProvider (created by ApplicationContainer)
in GlobalFormWrapper (created by ApplicationContainer)
in ApplicationContainer (created by DatApp)
in DatApp
in RCTView (created by View)
in View (created by AppContainer)
in RCTView (created by View)
in View (created by AppContainer)
in AppContainer
in dat.app(RootComponent)
|
Hey @Mugambi-Ian so you are getting this exception in debug? Are you able to reproduce it consistently or did it happen just one time? Our line of interest is
CREATE_FUNCTION("getIndexMMKV", 2, {
@try {
MMKV *kv = getInstance(nsstring(arguments[1]));
if (!kv) return Value::undefined();
NSMutableDictionary *keys = getIndex(kv, nsstring(arguments[0]));
return Value(convertNSArrayToJSIArray(runtime, [keys allKeys]));
} @catch(NSException *e) {
NSLog("%@", e.reason) //<< Add a breakpoint here in xcode.
}
});
Add a breakpoint at |
For some reason I cannot find any native crash logs related to MMKV and haven't experienced the error appearing as a redbox, however from our logging tools I have had it reported from my own test device in release mode. Given that it is showing up in Sentry as "handled" and I'm not seeing a redbox for it, it seems that not using the hook results in the error being captured without actually crashing the app. I don't fully understand this behaviour.
We are currently working on downgrading our
Your assumption is correct, we have no use of
The issue does not only happen on app upgrade. It is happening during app usage as well for keys that were already modified during the upgrade. We're not sure if it only affects new users because we updated this package during a period where we unrelatedly lost all crash reporting which has complicated and delayed our investigation of this issue. One additional very important point to note is that since upgrading from 0.9.1 we have observed some users who regularly have their redux store which is persisted with redux-persist using this package get removed (not sure if deletion, corruption, etc.) which effectively deletes the majority of the app state and makes the app function as if it's a fresh install. Some of our users experience this frequently while some not at all, and it often happens during app usage (not just at startup). We haven't tracked down if this is related to this HostFunction issue or separate. |
Hey @mmmoussa I would not recommend downgrading your react-native-mmkv-storage version as 0.10.x and newer versions included a breaking change in how storage indexer works. i would recommend disabling indexing and pushing a release out with the latest version to see if that will fix the issue which I am sure will. FYI i have been using react-native-mmkv-storage in my projects and I haven't seen the above issues on iOS for some reason. Since I don't use indexing, I have it disabled AFIK and I believe the issue is certainly related to that since that's the only major difference between 0.9 and 0.10 releases. |
I am unable to reproduce this issue locally, it only appeared for me once on macos app supported by m1 chip, and disappeared when I did a clear storage. This what made me release a new update for ios that clears unimportant storages, and just keeps very important storage like user app settings. This decreased the user crashes completely, I sometimes get report from users about something not working and I advice them to completely uninstall and reinstall the app and that fixed it for them. So the impact on users is really small percentage too 1-5% of iOS users. what I can confirm for me:
|
@ammarahm-ed I was able to resolve it by doing a clean app install. I had to uninstall and reinstall and the error disappeared. Now I need to figure out how to tell the current users to repeat this😅 |
@kashmiry Thanks for the sharing this detailed info. Were you able to reproduce the error consistently after upgrade (when you faced the error). What if you try downgrading the app to older version then upgrading to debug. That should probably show the error again I believe using the steps mentioned in #363 (comment). I have tried doing the same on multiple devices but I am unable to catch the error when upgrading, so i believe there's so special case that's getting unhandled probably. |
@Mugambi-Ian That's good to know. However It would be great if you can possibly try to reproduce the issue by downgrading your app version in debug, then upgrading again in debug mode. See if you face the issue again so we can properly fix it in the library. If possible follow #363 (comment) |
I just tried to install previous release on the same affected device, and then upgraded to the build that caused the issue, made sure to comment out the clearStorage fix so its not applied. But the issue was not reproduced. |
Disabled indexing on v0.11.2 but still seeing the same exception. This is my initialization for reference:
|
How are you able to test so quickly? Are you testing on test-flight release or is it being reproduced on your release app build locally? |
Saw the error flagged from my testflight release, which is also pending review from Apple. Will do further testing tomorrow with local release builds as well. |
@mmmoussa I will create another alpha release of the lib with some logging and error reporting to help track down the issue. |
Wow, I'm sorry for missing this discussion after starting it @ammarahm-ed I got busy with other things. Currently on v0.10.3 |
Describe the bug
There seems to be an issue with initializing this hook.
This does not happen with
0.9.1
and it seems to be mostly an iOS issue. Hopefully that will help in narrowing it down.I'm also not able to reproduce it on a debug build. Not sure why that is exactly.
For the time being I downgraded my MMVK package and it's working fine.
I have also noticed that it's crashing when we have users trying to "update" their app with the downgraded version.
edit
I found when clearing the library cache of the current user and then having them re-log in, all seems well. So it seems like there is something the old version of the lib is binding that the new version of the lib is not finding properly.
To Reproduce
Steps to reproduce the behavior:
useMMKVStorage()
hookExpected behavior
It returns
false
if the value is not there.Screenshots
App crashes with
Exception in HostFunction: <unknown>
How I'm initializing the storage
Platform Information:
The text was updated successfully, but these errors were encountered: