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

Fix - TextInput Drawable to avoid Null Pointer Exception RuntimeError #17530 #29452

Closed
wants to merge 18 commits into from

Commits on Jul 21, 2020

  1. Fix Drawable Runtime - More Info in Description

    The AppCompat Theme Theme.AppCompat.Light.NoActionBar provides a default
    Drawable resource for AppCompatEditText. The resource is located in
    @drawable/abc_edit_text_material.xml
    
    https://chromium.googlesource.com/android_tools/+/7200281446186c7192cb02f54dc2b38e02d705e5/sdk/extras/android/support/v7/appcompat/res/drawable/abc_edit_text_material.xml
    
    A Runtime Error is triggered in a scenario with the following conditions:
    
    1) Rendering a large number of TextInputs in the screen with a key prop
    2) Triggering re-render with setInterval
    
    The scenario is also experienced with FlatList and ONLY using TextInput
    component.
    
    The following Runtime Error is triggered:
    
    NullPointerException:tempt to invoke virtual method 'android.graphics.drawable.Drawable android.graphics.drawable.Drawable$ConstantState.newDrawable(android.content.res.Resources)
    
    It is caused from the following line from abc_edit_text_material.xml
    
    <item android:state_pressed="false" android:state_focused="false" android:drawable="@drawable/abc_textfield_default_mtrl_alpha"/>
    
    I posted a Minimal Reproducible Example at facebook#17530 (comment)
    
    This commit simply changes RNTester to use a custom drawable resource
    for TextInput named @drawable/edit_text.
    fabOnReact committed Jul 21, 2020
    Configuration menu
    Copy the full SHA
    0858d41 View commit details
    Browse the repository at this point in the history
  2. RNTester Minimum Reproducible Example

    A Minimum Reproducible Example that triggers the Null Pointer Exception
    Runtime Error NullPointerException:tempt to invoke virtual method 'android.graphics.drawable.Drawable android.graphics.drawable.Drawable$ConstantState.newDrawable(android.content.res.Resources)'
    
    The following are the conditions that trigger the runtime error:
    
    1) a large list (>100) TextInputs with key prop
    2) with FlatList passing prop data=[{key: 1, key:2,.., key:5000]]
    3) trigger re-render to ensure the NPE Runtime Error is triggered
    
    The example is built using hooks useEffect similar to componentDidMount.
    Original post is here
    facebook#17530 (comment)
    fabOnReact committed Jul 21, 2020
    Configuration menu
    Copy the full SHA
    4a414e2 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    e488a41 View commit details
    Browse the repository at this point in the history
  4. remove line from file

    fabOnReact committed Jul 21, 2020
    Configuration menu
    Copy the full SHA
    bddfcf6 View commit details
    Browse the repository at this point in the history
  5. updating template with custom drawable - more info

    Adding the edit_text.xml custom drawable to the android template to fix
    Null Pointer Exception Runtime Error from facebook#17530
    The template will include the following settings in new reactnative
    applications, more info on the issue, the cause of the error and the solution
    in commit 0858d41
    fabOnReact committed Jul 21, 2020
    Configuration menu
    Copy the full SHA
    f349308 View commit details
    Browse the repository at this point in the history

Commits on Jul 23, 2020

  1. Configuration menu
    Copy the full SHA
    a6d8c3d View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    0784187 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    b94aee8 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    a7951b7 View commit details
    Browse the repository at this point in the history

Commits on Aug 20, 2020

  1. Configuration menu
    Copy the full SHA
    b6ca5d3 View commit details
    Browse the repository at this point in the history

Commits on Aug 12, 2021

  1. Configuration menu
    Copy the full SHA
    c801edc View commit details
    Browse the repository at this point in the history

Commits on Sep 15, 2021

  1. Configuration menu
    Copy the full SHA
    d4bc8dd View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    73ffe69 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    9a544a0 View commit details
    Browse the repository at this point in the history
  4. minor format change

    fabOnReact committed Sep 15, 2021
    Configuration menu
    Copy the full SHA
    a6cd589 View commit details
    Browse the repository at this point in the history

Commits on Sep 22, 2021

  1. Configuration menu
    Copy the full SHA
    6c7b3d0 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    1da8a14 View commit details
    Browse the repository at this point in the history
  3. fix failing CI test

    fabOnReact committed Sep 22, 2021
    Configuration menu
    Copy the full SHA
    c447b25 View commit details
    Browse the repository at this point in the history