-
-
Notifications
You must be signed in to change notification settings - Fork 247
[Android] SafeAreaUtils.getFrame crash after update to v3.1.8 #159
Description
Aloha!
We've been happily using your safe-area-context for a while now, and love it, thanks for the great package!
Recently when we updated to v3.1.8, (coming all the way from 0.7.3), we've started to notice some crashes coming in from FirebaseCrashlytics, however haven't been able to reproduce any of these ourselves!
Fatal Exception: java.lang.NullPointerException
Attempt to invoke virtual method 'android.view.ViewParent android.view.View.getParent()' on a null object reference
com.th3rdwave.safeareacontext.SafeAreaUtils.getFrame (SafeAreaUtils.java:66)
com.th3rdwave.safeareacontext.SafeAreaProviderManager.getInitialWindowMetrics (SafeAreaProviderManager.java:72)
com.th3rdwave.safeareacontext.SafeAreaProviderManager.getExportedViewConstants (SafeAreaProviderManager.java:88)
com.facebook.react.uimanager.UIManagerModuleConstantsHelper.createConstantsForViewManager (UIManagerModuleConstantsHelper.java:132)
com.facebook.react.uimanager.UIManagerModuleConstantsHelper.createConstants (UIManagerModuleConstantsHelper.java:91)
com.facebook.react.uimanager.UIManagerModule.createConstants (UIManagerModule.java:276)
com.facebook.react.uimanager.UIManagerModule.<init> (UIManagerModule.java:183)
com.facebook.react.uimanager.UIManagerModule.<init> (UIManagerModule.java:144)
com.facebook.react.CoreModulesPackage.createUIManager (CoreModulesPackage.java:190)
com.facebook.react.CoreModulesPackage.getModule (CoreModulesPackage.java:158)
com.facebook.react.TurboReactPackage$ModuleHolderProvider.get (TurboReactPackage.java:159)
com.facebook.react.TurboReactPackage$ModuleHolderProvider.get (TurboReactPackage.java:147)
com.facebook.react.bridge.ModuleHolder.create (ModuleHolder.java:191)
com.facebook.react.bridge.ModuleHolder.getModule (ModuleHolder.java:156)
com.facebook.react.bridge.NativeModuleRegistry.getModule (NativeModuleRegistry.java:149)
com.facebook.react.bridge.CatalystInstanceImpl.getNativeModule (CatalystInstanceImpl.java:596)
com.facebook.react.bridge.CatalystInstanceImpl.getNativeModule (CatalystInstanceImpl.java:566)
com.facebook.react.uimanager.UIManagerHelper.getUIManager (UIManagerHelper.java:70)
com.facebook.react.uimanager.UIManagerHelper.getUIManager (UIManagerHelper.java:38)
com.facebook.react.ReactInstanceManager.attachRootViewToInstance (ReactInstanceManager.java:1136)
com.facebook.react.ReactInstanceManager.setupReactContext (ReactInstanceManager.java:1083)
com.facebook.react.ReactInstanceManager.access$1500 (ReactInstanceManager.java:131)
com.facebook.react.ReactInstanceManager$5$2.run (ReactInstanceManager.java:1037)
Which looks to be this line:
https://github.com/th3rdwave/react-native-safe-area-context/blob/master/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaUtils.java#L64-L68
And seems to be happening across multiple different devices as well:

I can't share all of our code, (and since I'm not able to reproduce this crash, I'm not sure if a small example would be that helpful), but our usage looks like:
App.tsx
return (
<IntlProvider
locale={clientLocale}
messages={translationsForUsersLocale}
onError={onIntlError}
>
<TokenProvider>
<SessionProvider>
<ApolloClientProvider>
<AccountProvider>
<UserProvider>
<SafeAreaProvider initialMetrics={initialWindowMetrics}>
<NavigationContainer ref={navigationRef}>
<TabNavigation tabs={ROOT_TABS} />
</NavigationContainer>
</SafeAreaProvider>
</UserProvider>
</AccountProvider>
</ApolloClientProvider>
</SessionProvider>
</TokenProvider>
</IntlProvider>
);In an overlay component
const insets = useSafeAreaInsets();
return (
<View>
<LotsOfMoreViews/>
<View
style={[
styles.ourCustomAddButton,
{
paddingBottom: insets.bottom + styles.customAddButton.paddingBottom,
},
]}
>
<CustomAddButon />
</View>
);In our React Navigation BottomTabs
const insets = useSafeAreaInsets();
return (
<View
style={[styles.navBar, { marginBottom: insets.bottom }]}
>
// Wraps all of our tabs
</View>
);Let me know if there's any other information that would be useful, and I'll update this ticket if I find anything else as well!