Skip to content

java.lang.NullPointerException: Attempt to invoke virtual method 'void com.facebook.react.uimanager.ReactShadowNode.setStyleWidth(float)' on a null object reference #10845

Closed
@akzhou

Description

@akzhou

Android tablet,when I assembleRelease the apk,modal view crash. debug not found this question.

java.lang.NullPointerException: Attempt to invoke virtual method 'void com.facebook.react.uimanager.ReactShadowNode.setStyleWidth(float)' on a null object reference at com.facebook.react.uimanager.UIImplementation.updateNodeSize(UIImplementation.java:151) at com.facebook.react.uimanager.UIManagerModule.updateNodeSize(UIManagerModule.java:213) at com.facebook.react.views.modal.ReactModalHostView$DialogRootViewGroup$1.run(ReactModalHostView.java:302) at android.os.Handler.handleCallback(Handler.java:815) at android.os.Handler.dispatchMessage(Handler.java:104) at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31) at android.os.Looper.loop(Looper.java:194) at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:196) at java.lang.Thread.run(Thread.java:818)

Additional Information

  • React Native version: 0.36.1,0.37
  • Platform: android
  • Operating System: mac os

Activity

ettysekhon

ettysekhon commented on Nov 11, 2016

@ettysekhon

I have found the same issue on release APK alse see #10795

ettysekhon

ettysekhon commented on Nov 11, 2016

@ettysekhon

@akzhou I solved this by using the InteractionManager runAfterInteractions in a ComponentDidMount, see below for further details:

https://github.com/brentvatne/run-after-interactions-exp/blob/master/index.js

ettysekhon

ettysekhon commented on Nov 11, 2016

@ettysekhon

@akzhou I solved this by using the InteractionManager runAfterInteractions in a ComponentDidMount, see below for further details:

https://github.com/brentvatne/run-after-interactions-exp/blob/master/index.js

akzhou

akzhou commented on Nov 16, 2016

@akzhou
Author

@ettysekhon it seem that you use renderPlaceholder replace modal view.at last,I fix it by compile the react-native source code with modify ReactModalHostView.java onSizeChanged method
protected void onSizeChanged(final int w, final int h, int oldw, int oldh) { super.onSizeChanged(w, h, oldw, oldh); return }
i don't know how the code work,at least no crash

xujinyang

xujinyang commented on Nov 22, 2016

@xujinyang
Contributor

@akzhou can you push an PR to facebook?

nadeermalangadan

nadeermalangadan commented on Nov 22, 2016

@nadeermalangadan

+1

bawn

bawn commented on Nov 25, 2016

@bawn

+1

Proberts

Proberts commented on Nov 29, 2016

@Proberts

This fix looks like it removes some important functionality.

FWIW I have this reproducible using redux and saga. I have a bool state variable mapped to a Modal component's 'visible" property. I change the state from false to true at the start of the saga. If I change the state back to false in the same saga I get this error consistently.

It seems like a safer band-aid would be to put a null test at line 151 (RN 0.37) in UIImplementation.java:

public void updateNodeSize(
      int nodeViewTag,
      int newWidth,
      int newHeight) {
    ReactShadowNode cssNode = mShadowNodeRegistry.getNode(nodeViewTag);
      if( cssNode != null ) {  // <-- right here
        cssNode.setStyleWidth(newWidth);
        cssNode.setStyleHeight(newHeight);
      }

    // If we're in the middle of a batch, the change will automatically be dispatched at the end of
    // the batch. As all batches are executed as a single runnable on the event queue this should
    // always be empty, but that calling architecture is an implementation detail.
    if (mOperationsQueue.isEmpty()) {
      dispatchViewUpdates(-1); // -1 = no associated batch id
    }
  }
idris

idris commented on Nov 29, 2016

@idris

@Proberts can you create an app that reproduces this issue on https://rnplay.org and then attach it to #10795?

Proberts

Proberts commented on Nov 29, 2016

@Proberts

@idris Trying but it looks like I can't import redux-saga. Not sure how to implement it without as I'm new to RN. I can try to make a minimal app that shows the problem and stick it on github. Would that help?

idris

idris commented on Dec 1, 2016

@idris

@Proberts yeah that would probably be useful for react-native devs to have a way to reproduce it.

jjdp

jjdp commented on Dec 8, 2016

@jjdp

+1

Proberts

Proberts commented on Dec 8, 2016

@Proberts

FWIW I can't get it to reproduce in a minimal setup with the way I thought it was getting triggered in my code. I had it go away for a while after I moved some code being called from an onPress event handler into a saga. But it came back after I added to async calls to the saga - so at least I have a place to start looking.

jideobs

jideobs commented on Dec 8, 2016

@jideobs

This problem is fresh. +1

66 remaining items

astreet

astreet commented on May 10, 2017

@astreet
Contributor

Yes, .44 should be fine as it's listed in the release notes: https://github.com/facebook/react-native/releases/tag/v0.44.0

39otrebla

39otrebla commented on Sep 15, 2017

@39otrebla

Still happening on my side, without using any Modal (I am using react native navigation and its built-in Modal).

platform: Android (min api 21)
react-native: 0.48.3

couldhll

couldhll commented on Nov 22, 2017

@couldhll

+1

mehmetcanker

mehmetcanker commented on Nov 22, 2017

@mehmetcanker

+1

Shinichi52

Shinichi52 commented on Nov 27, 2017

@Shinichi52

+1

etruta

etruta commented on Dec 19, 2017

@etruta

+1

fxalvarezd

fxalvarezd commented on Jan 29, 2018

@fxalvarezd

@astreet not sure if you have any input on this. I have the same issue as @39otrebla described.
It's really random on our end and almost never happens, but when it does it's when transitioning to a screen.
We're running react-native: 0.48.4 and react-native-navigation: ^1.1.300.

wenkangzhou

wenkangzhou commented on Jun 1, 2018

@wenkangzhou

Still happening in 0.49.5

8of

8of commented on Jul 12, 2018

@8of

The issue is still here, unfortunately.
React Native 0.55.4, 0.56.0
Android 8

locked as resolved and limited conversation to collaborators on Jul 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @idris@etruta@cemo@zubryan@Cooke

        Issue actions

          java.lang.NullPointerException: Attempt to invoke virtual method 'void com.facebook.react.uimanager.ReactShadowNode.setStyleWidth(float)' on a null object reference · Issue #10845 · facebook/react-native