App: [$2000] Identify source and fix crash: `com.facebook.react.views.textinput.ReactTextInputShadowNode.createInternalEditText`

Fatal Exception: java.lang.NullPointerException

Attempt to invoke virtual method ‘android.graphics.drawable.Drawable android.graphics.drawable.Drawable$ConstantState.newDrawable(android.content.res.Resources)’ on a null object reference

ReactTextInputShadowNode.java line 265 com.facebook.react.views.textinput.ReactTextInputShadowNode.createInternalEditText

Number of Crashes: 6

Device Information

  • Platforms: Android
  • App Versions: 1.1.84-9
  • Devices: Google Pixel 6 12

Stacktraces

Android 1.1.84-9
android.graphics.drawable.DrawableContainer$DrawableContainerState.createAllFutures (DrawableContainer.java:879)
android.graphics.drawable.DrawableContainer$DrawableContainerState.getOpacity (DrawableContainer.java:1162)
android.graphics.drawable.DrawableContainer.getOpacity (DrawableContainer.java:433)
android.graphics.drawable.InsetDrawable.getOpacity (InsetDrawable.java:260)
android.view.View.computeOpaqueFlags (View.java:18947)
android.view.View.setBackgroundDrawable (View.java:24066)
android.view.View.setBackground (View.java:23959)
android.view.View.<init> (View.java:6028)
android.widget.TextView.<init> (TextView.java:1032)
android.widget.EditText.<init> (EditText.java:87)
android.widget.EditText.<init> (EditText.java:83)
android.widget.EditText.<init> (EditText.java:79)
android.widget.EditText.<init> (EditText.java:75)
com.facebook.react.views.textinput.ReactTextInputShadowNode.createInternalEditText (ReactTextInputShadowNode.java:265)
com.facebook.react.views.textinput.ReactTextInputShadowNode.setThemedContext (ReactTextInputShadowNode.java:85)
com.facebook.react.uimanager.UIImplementation.createView (UIImplementation.java:254)
com.facebook.react.uimanager.UIManagerModule.createView (UIManagerModule.java:508)
com.facebook.react.uimanager.ReanimatedUIManager.createView (ReanimatedUIManager.java:72)
java.lang.reflect.Method.invoke
com.facebook.react.bridge.JavaMethodWrapper.invoke (JavaMethodWrapper.java:372)
com.facebook.react.bridge.JavaModuleWrapper.invoke (JavaModuleWrapper.java:188)
com.facebook.react.bridge.queue.NativeRunnable.run
android.os.Handler.handleCallback (Handler.java:938)
android.os.Handler.dispatchMessage (Handler.java:99)
com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage (MessageQueueThreadHandler.java:27)
android.os.Looper.loopOnce (Looper.java:201)
android.os.Looper.loop (Looper.java:288)
com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run (MessageQueueThreadImpl.java:226)
java.lang.Thread.run (Thread.java:920)

Internal Firebase Info

💥 DO NOT EDIT THIS SECTION 💥

Crash IDs: 42000df8ef8cae0122bacbb4c7656d31 Exception: Attempt to invoke virtual method 'android.graphics.drawable.Drawable android.graphics.drawable.Drawable$ConstantState.newDrawable(android.content.res.Resources)' on a null object reference

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 27 (23 by maintainers)

Most upvoted comments

I agree we can close this issue out as the crash did not occur in a while. Also I think we should compensate part of the full price to @dhairyasenjaliya for their investigation and confirming this should be fixed by RN update.

@dylanexpensify we shouldn’t double.

I agree with @dhairyasenjaliya’s investigation and this issue can be closed.

@rushatgabhane this issue is fixed while upgrading the RN version to 0.69 here by adding the rn_edit_text_material file in androidManifest file

I also have mentioned steps to reproduce which you check real-time by adding above file actually fixed the issue

Screenshot 2022-09-05 at 11 28 40 PM

Maybe it’s because Melvin is scheduled to update the bug weekly??

I believe melvin checks every 15mins if there are any crash updates from firebase. Only if there are any new changes to report then it updates the GH issue.

Proposal

Root Cause

This bug is very tricky and one cannot be reproduced simply, so for that I have created one minimal demo In order to check if this is actually resolved

  • Note : If we want this crash reproducible in android please follow below steps

1. Comment or remove this line (clean and rebuild android) https://github.com/Expensify/App/blob/dbfd0eb5ae2cd321db5075f088492f87ff1e8860/android/app/src/main/res/values/styles.xml#L11

2. Add snippet as mentioned

<FlatList // eslint-disable-next-line max-len, rulesdir/prefer-underscore-method data={Array(1000).fill().map(() => Math.round(Math.random() * 1000))} renderItem={(data, index) => ( <View> <TextInput key={new Date()} value="test" /> </View> )} />

3. Uninstall old apk and re-run android

4. Live Re-load app a couple of times to reproduce and see a crash (command+s into VS code while being on SidebarLinks)

Results

Fix With rn_edit_text_material file

solveMinimumReproducable solveNativeLine

Crash Without rn_edit_text_material file

crashMinimumReproducable crashNativeLine