Skip to content
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

Open
CoryWritesCode opened this issue Oct 22, 2024 · 30 comments
Open

[Bug] App crashing when using useMMKVStorage hook #363

CoryWritesCode opened this issue Oct 22, 2024 · 30 comments

Comments

@CoryWritesCode
Copy link

CoryWritesCode commented Oct 22, 2024

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:

  1. Use the useMMKVStorage() hook

Expected behavior
It returns false if the value is not there.

Screenshots
App crashes with Exception in HostFunction: <unknown>
image

How I'm initializing the storage
image

Platform Information:

  • OS: Seems to mostly be iOS related.
  • React Native Version 0.74.5
  • Library Version 0.10.3
@CoryWritesCode
Copy link
Author

@ammarahm-ed pinging only because this is a pretty intense issue

@kashmiry
Copy link

kashmiry commented Oct 24, 2024

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.
Example when performing:
postsStorage.removeItem() an error is thrown with Exception in HostFunction: <unknown>.
I only experienced it on my m1 macos version of the app. although I am still getting crash reports from users devices on different versions on iPhone.
The issue seems to be gone when performing a reset to affected storages. example: postsStorage.clearStore();
An urgent fix for this would be appreciated.

Version:
react-native: 0.74.6
react-native-mmkv-storage: 0.10.3

@ammarahm-ed
Copy link
Owner

I will look into this, would greatly appreciate if someone can provide crash logs from the release build

@kashmiry
Copy link

kashmiry commented Oct 26, 2024

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.
its pointing to the removeItem() function when screen unmounts.
I experienced this same error once on my device, but was gone when performed a clearStore()
maybe someone else can offer a better crash log too.

Fatal Exception: RCTFatalException: Unhandled JS Exception: Error: Exception in HostFunction: <unknown> This error is located at: in Post in StaticContainer in EnsureSingleNavigator in SceneView in RCTView in Unknown in DebugContainer in MaybeNestedStack in RCTView in Unknown in RNSScreen in Unknown in Suspender in Suspense in Freeze in DelayedFreeze in InnerScreen in Screen in SceneView in Suspender in Suspense in Freeze in DelayedFreeze, js engine: hermes
Unhandled JS Exception: Error: Exception in HostFunction: <unknown> This error is located at: in Post in StaticContainer in EnsureSingleNavigator in SceneVie..., stack: handleAction@110862:29 removeItem@110056:69 anonymous@284779:156 safelyCallDestroy@30216:13 commitHookEffectListUnmount@30279:79 commitPassiveUnmountEffectsInsideOfDeletedTree_begin@31029:37 recursivelyTraversePassiveUnmountEffects@30971:60 commitPassiveUnmountOnFiber@30990:48 recursivelyTraversePassiveUnmountEffects@30975:130 commitPassiveUnmountOnFiber@30982:48 recursivelyTraversePassiveUnmountEffects@30975:130 commitPassiveUnmountOnFiber@30982:48 recursivelyTraversePassiveUnmountEffects@30975:130 commitPassiveUnmountOnFiber@30990:48 recursivelyTraversePassiveUnmountEffects@30975:130 commitPassiveUnmountOnFiber@30982:48 recursivelyTraversePassiveUnmountEffects@30975:130 commitPassiveUnmountOnFiber@30982:48 recursivelyTraversePassiveUnmountEffects@30975:130 commitPassiveUnmountOnFiber@30982:48 recursivelyTraversePassiveUnmountEffects@30975:130 commitPassiveUnmountOnFiber@30990:48 recursivelyTraversePassiveUnmountEffects@30975:130 commitPassiveUnmountOnFiber@30982:48 recursivelyTraversePassiveUnmountEffects@30975:130 commitPassiveUnmountOnFiber@30990:48 recursivelyTraversePassiveUnmountEffects@30975:130 commitPassiveUnmountOnFiber@30982:48 recursivelyTraversePassiveUnmountEffects@30975:130 commitPassiveUnmountOnFiber@30982:48 recursivelyTraversePassiveUnmountEffects@30975:130 commitPassiveUnmountOnFiber@30982:48 recursivelyTraversePassiveUnmountEffects@30975:130 commitPassiveUnmountOnFiber@30982:48 recursivelyTraversePassiveUnmountEffects@30975:130 commitPassiveUnmountOnFiber@30982:48 recursivelyTraversePassiveUnmountEffects@30975:130 commitPassiveUnmountOnFiber@30990:48 recursivelyTraversePassiveUnmountEffects@30975:130 commitPassiveUnmountOnFiber@30990:48 recursivelyTraversePassiveUnmountEffects@30975:130 commitPassiveUnmountOnFiber@30982:48 recursivelyTraversePassiveUnmountEffects@30975:130 commitPassiveUnmountOnFiber@30990:4
 Fatal Exception: RCTFatalException: Unhandled JS Exception: Error: Exception in HostFunction: <unknown>

This error is located at:
    in Post
    in StaticContainer
    in EnsureSingleNavigator
    in SceneView
    in RCTView
    in Unknown
    in DebugContainer
    in MaybeNestedStack
    in RCTView
    in Unknown
    in RNSScreen
    in Unknown
    in Suspender
    in Suspense
    in Freeze
    in DelayedFreeze
    in InnerScreen
    in Screen
    in SceneView
    in Suspender
    in Suspense
    in Freeze
    in DelayedFreeze, js engine: hermes
0  CoreFoundation                 0x8408c __exceptionPreprocess
1  libobjc.A.dylib                0x172e4 objc_exception_throw
2  reactapp                     0x4e1668 RCTFormatError + 167 (RCTAssert.m:167)
3  reactapp                     0x23260 -[RCTExceptionsManager reportFatal:stack:exceptionId:extraDataAsJSON:] + 82 (RCTExceptionsManager.mm:82)
4  reactapp                     0x23a88 -[RCTExceptionsManager reportException:] + 154 (RCTExceptionsManager.mm:154)
5  CoreFoundation                 0x210f4 __invoking___
6  CoreFoundation                 0x20144 -[NSInvocation invoke]
7  CoreFoundation                 0x96578 -[NSInvocation invokeWithTarget:]
8  reactapp                     0x5163c4 -[RCTModuleMethod invokeWithBridge:module:arguments:] + 587 (RCTModuleMethod.mm:587)
9  reactapp                     0x5184d8 facebook::react::invokeInner(RCTBridge*, RCTModuleData*, unsigned int, folly::dynamic const&, int, (anonymous namespace)::SchedulingContext) + 196 (RCTNativeModule.mm:196)
10 reactapp                     0x51812c invocation function for block in facebook::react::RCTNativeModule::invoke(unsigned int, folly::dynamic&&, int) + 298 (optional:298)
11 libdispatch.dylib              0x2370 _dispatch_call_block_and_release
12 libdispatch.dylib              0x40d0 _dispatch_client_callout
13 libdispatch.dylib              0xb6d8 _dispatch_lane_serial_drain
14 libdispatch.dylib              0xc1e0 _dispatch_lane_invoke
15 libdispatch.dylib              0x17258 _dispatch_root_queue_drain_deferred_wlh
16 libdispatch.dylib              0x16aa4 _dispatch_workloop_worker_thread
17 libsystem_pthread.dylib        0x4c7c _pthread_wqthread
18 libsystem_pthread.dylib        0x1488 start_wqthread

@mmmoussa
Copy link
Contributor

We've got the same issue with very high prevalence, particularly when dealing with setting or removing our stored navigation state. Below are some stacktraces from our release build:
Screenshot 2024-10-28 at 9 44 12 AM
Screenshot 2024-10-28 at 12 52 03 PM

@ammarahm-ed
Copy link
Owner

Thanks @mmmoussa I am looking into the issue

@ammarahm-ed
Copy link
Owner

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.

@mmmoussa
Copy link
Contributor

mmmoussa commented Nov 3, 2024

@ammarahm-ed the app doesn't build on iOS with the latest version and the old architecture, due to the following issue:
Screenshot 2024-11-03 at 7 04 25 AM

@ammarahm-ed
Copy link
Owner

Hey @mmmoussa try v0.11.0. It should probably fix the build error.

@mmmoussa
Copy link
Contributor

mmmoussa commented Nov 3, 2024

Tried v0.11.1 and it failed with a different error:
Screenshot 2024-11-03 at 10 17 25 AM

@ammarahm-ed
Copy link
Owner

It builds fine on RN 0.76. Let me try on an older version.

@ammarahm-ed
Copy link
Owner

ammarahm-ed commented Nov 3, 2024

Hey @mmmoussa Just released v0.11.2, can you try now. Make sure to delete Pods & build folders inside your project's ios folder.

@mmmoussa
Copy link
Contributor

mmmoussa commented Nov 3, 2024

Build is now working on RN 0.75.4. Will circle back regarding the actual issue being observed.

@mmmoussa
Copy link
Contributor

mmmoussa commented Nov 3, 2024

Issue is not resolved by v0.11.2

@ammarahm-ed
Copy link
Owner

ammarahm-ed commented Nov 4, 2024

Can you provide any native crash logs? You can find any native crash logs related to MMKV from Xcode -> Organizer -> Crashes. Are you able to reproduce this issue locally on your test devices in release or debug mode?

Can you try initializing your MMKV with new MMKVLoader().disableIndexing().initialize(). Simply add the disableIndexing() call to your builder.

Do this for MMKV instance that is not used by useMMKVStorage hooks. I am assuming your AppContextMMKV is not used in a useMMKVStorage Hook.

Also can you confirm if the issue is only happening to people who are upgrading the app. The new installs work as expected?

@ammarahm-ed
Copy link
Owner

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.

@Mugambi-Ian
Copy link

Mugambi-Ian commented Nov 5, 2024

@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.
Screenshot 2024-11-05 at 7 29 09 AM

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)

@ammarahm-ed
Copy link
Owner

ammarahm-ed commented Nov 5, 2024

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 Warning: Error: Exception in HostFunction: <unknown> but it doesn't tell us what went wrong exactly. There is one way to check though if you can:

  1. Open Xcode .xcworkspace
  2. Go to Pods -> Development Pods -> react-native-mmkv-storage -> MMKVStorage.mm
  3. Search fo getIndexMMMV function
  4. Wrap the function body in a @Try @catch block. Something like below:
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 NSLog(.... Check if you are able to catch the exact error that occured.

@mmmoussa
Copy link
Contributor

mmmoussa commented Nov 5, 2024

@ammarahm-ed

Can you provide any native crash logs? You can find any native crash logs related to MMKV from Xcode -> Organizer -> Crashes. Are you able to reproduce this issue locally on your test devices in release or debug mode?

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.

Can you try initializing your MMKV with new MMKVLoader().disableIndexing().initialize(). Simply add the disableIndexing() call to your builder.

We are currently working on downgrading our react-native-mmkv-storage version to see if that will resolve this issue and another (mentioned below) that we are experiencing since upgrading this package.

Do this for MMKV instance that is not used by useMMKVStorage hooks. I am assuming your AppContextMMKV is not used in a useMMKVStorage Hook.

Your assumption is correct, we have no use of useMMKVStorage in our app.

Also can you confirm if the issue is only happening to people who are upgrading the app. The new installs work as expected?

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.

@ammarahm-ed
Copy link
Owner

ammarahm-ed commented Nov 5, 2024

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.

@kashmiry
Copy link

kashmiry commented Nov 5, 2024

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.

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.
I will try the latest updates on my next release and report if I found any thing helpful.

what I can confirm for me:

  • Its happens on iOS after upgrade.
  • Affected storages can not store new items, and will not fire a crash. example: .setMap will not save new data, but will fail silently or with a warning.
  • The crash is triggered via .removeItem on affected storages.

@Mugambi-Ian
Copy link

Mugambi-Ian commented Nov 5, 2024

@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😅

@ammarahm-ed
Copy link
Owner

ammarahm-ed commented Nov 5, 2024

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

@ammarahm-ed
Copy link
Owner

ammarahm-ed commented Nov 5, 2024

@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)

@kashmiry
Copy link

kashmiry commented Nov 5, 2024

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

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.
I hope others can reproduce this successfully and catch the log.

@mmmoussa
Copy link
Contributor

mmmoussa commented Nov 5, 2024

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.

Disabled indexing on v0.11.2 but still seeing the same exception.

This is my initialization for reference:

export const AppContextMMKV = new MMKVLoader()
  .disableIndexing()
  .withInstanceID('AppContext')
  .initialize();

@ammarahm-ed
Copy link
Owner

ammarahm-ed commented Nov 5, 2024

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.

Disabled indexing on v0.11.2 but still seeing the same exception

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?

@mmmoussa
Copy link
Contributor

mmmoussa commented Nov 5, 2024

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.

Disabled indexing on v0.11.2 but still seeing the same exception

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.

@ammarahm-ed
Copy link
Owner

@mmmoussa I will create another alpha release of the lib with some logging and error reporting to help track down the issue.

@CoryWritesCode
Copy link
Author

Wow, I'm sorry for missing this discussion after starting it @ammarahm-ed I got busy with other things.
Here's what I know:
We experienced crashing whenever certain values were attempting to be retrieved on iOS after upgrading the app with the newer version. I was unable to reproduce it locally in a debug version ever, if maybe just once.
What we ended up doing as a fix is clearing the storage if a user experienced a crash with that issue in an ErrorBoundary. From there we noticed that when they reopened the app that the library seemed to clear out whatever bad indexing was occurring and the user was fine from there. Since we are a version past this initial fix, we haven't had any related crashes since.

Currently on v0.10.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants