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

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

Closed
melvin-bot bot opened this issue Jul 13, 2022 · 27 comments
Assignees
Labels
Engineering External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors Weekly KSv2

Comments

@melvin-bot
Copy link

melvin-bot bot commented Jul 13, 2022

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

@melvin-bot
Copy link
Author

melvin-bot bot commented Jul 19, 2022

Huh... This is 4 days overdue. Who can take care of this?

@melvin-bot melvin-bot bot added the Overdue label Jul 19, 2022
@flodnv flodnv added Weekly KSv2 and removed Daily KSv2 labels Jul 25, 2022
@melvin-bot melvin-bot bot removed the Overdue label Jul 25, 2022
@marcaaron marcaaron added the External Added to denote the issue can be worked on by a contributor label Aug 3, 2022
@melvin-bot melvin-bot bot added the Overdue label Aug 3, 2022
@melvin-bot
Copy link
Author

melvin-bot bot commented Aug 3, 2022

Triggered auto assignment to @dylanexpensify (External), see https://stackoverflow.com/c/expensify/questions/8582 for more details.

@melvin-bot melvin-bot bot added Daily KSv2 Overdue and removed Weekly KSv2 Overdue labels Aug 3, 2022
@dylanexpensify
Copy link
Contributor

Update coming today!

@melvin-bot melvin-bot bot removed the Overdue label Aug 9, 2022
@dylanexpensify
Copy link
Contributor

@marcaaron could I get an updated title for this issue so I could get it on Upwork? Thanks man!

@marcaaron marcaaron changed the title 💥 Crash 💥 com.facebook.react.views.textinput.ReactTextInputShadowNode.createInternalEditText Identify source and fix crash: com.facebook.react.views.textinput.ReactTextInputShadowNode.createInternalEditText Aug 10, 2022
@dylanexpensify
Copy link
Contributor

@melvin-bot melvin-bot bot added Weekly KSv2 and removed Daily KSv2 labels Aug 11, 2022
@melvin-bot
Copy link
Author

melvin-bot bot commented Aug 11, 2022

Triggered auto assignment to Contributor-plus team member for initial proposal review - @rushatgabhane (Exported)

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Aug 11, 2022
@melvin-bot
Copy link
Author

melvin-bot bot commented Aug 11, 2022

Triggered auto assignment to @chiragsalian (Exported), see https://stackoverflow.com/c/expensify/questions/7972 for more details.

@melvin-bot melvin-bot bot changed the title Identify source and fix crash: com.facebook.react.views.textinput.ReactTextInputShadowNode.createInternalEditText [$250] Identify source and fix crash: com.facebook.react.views.textinput.ReactTextInputShadowNode.createInternalEditText Aug 11, 2022
@melvin-bot melvin-bot bot added the Overdue label Aug 19, 2022
@dylanexpensify dylanexpensify changed the title [$1000] Identify source and fix crash: com.facebook.react.views.textinput.ReactTextInputShadowNode.createInternalEditText [$2000] Identify source and fix crash: com.facebook.react.views.textinput.ReactTextInputShadowNode.createInternalEditText Sep 5, 2022
@dylanexpensify
Copy link
Contributor

doubled

@dhairyasenjaliya
Copy link
Contributor

Proposal

Root Cause

  • This is a well-known issue in the older version of the react 0.66 related to the android material native style issue for the text input.
  • Recently this bug is being identified and resolved by adding one file rn_edit_text_material.xml into
    android/app/src/main/res/drawable/rn_edit_text_material.xml
  • After adding above file add this line <item name="android:editTextBackground">@drawable/rn_edit_text_material</item> into android/app/src/main/res/values/styles.xml file.
  • Here is the official doc of react native upgrader we can check in the android section for the above changes https://react-native-community.github.io/upgrade-helper/?from=0.66.0&to=0.69.4
  • Since we have already upgraded to 0.69 and also added the above-mentioned changes here so we don't need to add any additional changes.
    <item name="android:editTextBackground">@drawable/rn_edit_text_material</item>

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)

<item name="android:editTextBackground">@drawable/rn_edit_text_material</item>

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

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Sep 5, 2022
@rushatgabhane
Copy link
Member

rushatgabhane commented Sep 5, 2022

This is a well-known issue in the older version of the react 0.66 related to the android material native style issue for the text input.

@dhairyasenjaliya thanks for your detailed proposal!
This is the github link to the original react-native issue right? facebook/react-native#17530

Since we have already upgraded to 0.69 and also added the above-mentioned changes here so we don't need to add any additional changes.

I'm confused. What exactly do we need to change to fix this bug?

@dhairyasenjaliya
Copy link
Contributor

@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

@rushatgabhane
Copy link
Member

rushatgabhane commented Sep 5, 2022

@dhairyasenjaliya are you suggesting that this issue has been fixed already? And that we need to do nothing?

Because the file rn_edit_text_material is present on production
https://github.com/Expensify/App/blob/main/android/app/src/main/res/drawable/rn_edit_text_material.xml

@dhairyasenjaliya
Copy link
Contributor

dhairyasenjaliya commented Sep 5, 2022

@rushatgabhane yes as you check by just disabling rn_edit_text_material in androidManifest file and adding the code snippet that I added in the proposal to confirm just follow simple steps to reproduce

@rushatgabhane
Copy link
Member

rushatgabhane commented Sep 5, 2022

Thanks @dhairyasenjaliya

I agree with you! But that doesn't explain why there was a crash 10 days ago. RN upgrade was in production much before that

image

Maybe it's because Melvin is scheduled to update the bug weekly?? cc: @chiragsalian

@dhairyasenjaliya
Copy link
Contributor

dhairyasenjaliya commented Sep 5, 2022

hm @rushatgabhane I think that's because of the old app version used

  • issue was reproduced on 26th July app version 1.1.84-9

Screenshot 2022-09-06 at 12 20 53 AM

  • also the latest update edit (10 days ago) version is the same 1.1.84-9, if this error was caused by the latest then I do think the version also should be updated!

Screenshot 2022-09-06 at 12 21 37 AM

@chiragsalian
Copy link
Contributor

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.

@dylanexpensify dylanexpensify added Weekly KSv2 and removed Daily KSv2 labels Sep 6, 2022
@melvin-bot melvin-bot bot added the Overdue label Sep 15, 2022
@dylanexpensify
Copy link
Contributor

@chiragsalian should we double?

@melvin-bot melvin-bot bot removed the Overdue label Sep 15, 2022
@rushatgabhane
Copy link
Member

rushatgabhane commented Sep 15, 2022

@dylanexpensify we shouldn't double.

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

@rushatgabhane
Copy link
Member

rushatgabhane commented Sep 15, 2022

@dylanexpensify I'm curious if they'll be compensated for their investigation.

This is a "Identify source and fix crash" issue. Will it be treated any differently from regular issues where we always require a PR?

@melvin-bot melvin-bot bot added the Overdue label Sep 26, 2022
@dylanexpensify
Copy link
Contributor

@rushatgabhane sorry I missed this, let me check and report back

@melvin-bot melvin-bot bot removed the Overdue label Sep 27, 2022
@mountiny
Copy link
Contributor

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
Copy link
Contributor

@dhairyasenjaliya mind applying here?

@dhairyasenjaliya
Copy link
Contributor

applied, thank you, team :)

@dylanexpensify
Copy link
Contributor

Offer sent!

@dylanexpensify
Copy link
Contributor

payment sent, contract ended, job closed! thanks y'all!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Engineering External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors Weekly KSv2
Projects
None yet
Development

No branches or pull requests

7 participants