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)
I have found the same issue on release APK alse see https://github.com/facebook/react-native/issues/10795
@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 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 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
@akzhou can you push an PR to facebook?
+1
+1
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
}
}
@Proberts can you create an app that reproduces this issue on https://rnplay.org and then attach it to https://github.com/facebook/react-native/issues/10795?
@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?
@Proberts yeah that would probably be useful for react-native devs to have a way to reproduce it.
+1
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.
This problem is fresh. +1
We're also encountering this crash on Google Android emulators API 23, RN 0.35 with automated runs via Calabash. We haven't seen it (yet thankfully?) on physical devices, but it's pretty annoying to have our automation fail so randomly. It also happens around the time of a modal display.
I am having the same issue. I have modal (fullscreen) and android keyboard on. It happens when I close it with enter key (onSubmitEditing). I've tried to close modal in InteractionManager.runAfterInteractions
callback, but it didn't help.
However It seems to be working when I postpone it with setTimeout(..., 300)
I have the same question on React Native
Version: 0.30.0
Platform: Android (Coolpad A8-930)
+1
Any updates?
Any updates?
Yeah this bug is pretty nasty, i've got 2 bad reviews in play store because of it ...
I've used this fix
const CustomModal = ({ visible = false, children }) => {
if (!visible) {
return <View/>
}
return (
<Modal
style={styles.modalWrapper}
animationType='slide'
onRequestClose={() => {}}
visible={true}
transparent >
{children}
</Modal>
)
}
Nothing fancy, but works okay
I have the same question on React Native
Version: 0.39.0
Platform: Android
+1
I haven't seen this problem since I upgraded to 0.39.2 It might have been fixed by this commit
I've just seen it with 0.41-rc
+1 the same problem in RN 0.39 Android 4.4.4. Also cause with the Modal. I am a little upset.
Experiencing this randomly on startup as well. 0.4.0
+1 with version 0.40
I have manged to reproduce my version of this issue consistently and implemented a work-around (not battle-tested): https://github.com/Cooke/ReactNativeAndroidModalCrashBug/blob/master/index.android.js
Bump. Occurs with v0.39
I have faced same issue and was able to get around.
I use a boolean to determine visibility of a modal (loading modal in my case). When this boolean value changes value quickly from false to true (modal visible) and true to false (modal invisible), this was causing the crash (probably it was not able to re-render quickly). So I gave a delay of 0.5 seconds before closing the modal and it worked.
Also, when you are debugging, you would not be able to reproduce this issue. As debugging gives enough time, crash wont be seen.
As this use case was taking too small time, there was no need to show loading modal in my case. So I just removed it.
I just had this problem re-occur in a slightly different way, and while debugging in the emulator. Maybe this can help:
I have a boolean in the state controlling a modal's visibilily (isVisible). The default state for the boolean is true (show modal). I check status and set the state variable to false in componentWillMount() (using Dispatch). My emulator is updating very slowly and It appears as if the modal is partially drawn when the state variable flips, then the error occurs. It happens maybe 90% of the time. I can't seem to set the state anywhere in the component initialization that guarantees it will be set before rendering begins.
(I was able to fix this problem for my use case by negating the logic and defaulting to visible = false.)
+1 for 0.41.2
My company needed a fix for this, as this crash was happening in production and it was vital we fixed it, but we were unable to come up with a good method of testing and fixing this issue. We managed to "fix" the issue by ripping out the Modal component from our code. In our case, Modal was used to show a loading indicator.
We definitely need a fix for this issue though.
I'm having exact same problem, funny thing is that it happens randomly and the number of occurrences different between devices.
For example, I have Galaxy S7 Edge and I couldn't reproduce it but in the other hand, our QA has Galaxy S7 and he faced that issue frequently.
Please someone working on this project, let us know which version you will fix this problem? This should be prioritized as it causes annoying crashes.
Note for anybody reading we solved our problem but in our case it had nothing to do with the Modal.
It was a problem with how we were using react-native-router-flux. We were not managing the scene stack properly. Using Actions.pop() correctly fixed our problem.
hey guys, i had this problem with an input inside a modal, In my case the keyboard was being hidden when the submit button were being pressed, and i was closing the modal before the keyboard finish hiding, that flux was causing the error, the InteractionManager didn't help, so i had to put a setTimeout 200ms to wait and then hide the modal. hope this helps.
@praveenperera may you provide more details with what you were doing wrong with react-native-router-flux and what fixed it for you? Thanks!
happens in v0.38, on some devices. Modal on top of another modal was the cause of mine.
Same problem here, I'm using 0.40.0 on Android.
@praveenperera - does 0.41.2 have a fix for this?
Not yet. This issue is the most popular 15th issue according to comments and still there is not any comment from the dev team since the beginning of this issue. This issue really caused tremendous frustration on my side.
I also have the same issue.
I just added a delay of 1 sec before swaping to the view which solved this temporarily and there is no crash . This error is not encountered in debug mode, when we generate apk this error message pops up randomly.
I believe it is due to react-native-router-flux
i have similar issue , did anyone find solution to it or any one from development team would address this soon?
@ettysekhon can you provide your solution once again. The link mentioned in your comment shows "File not found".
I think it won't be easy to fix - as far as i've monitored it. I think it's the same Root Cause like: #10471 ( IOS ) correlated to Modal handling.
To specify this more clearly: Switching fast between "Modal Level" Items causes a lot of issues - even without animations. The current Implementation is highly sensitive towards these switches. I think it has something to do how these Modals are added to the rendering tree - without knowing about the internals.
Leading to the only conclusion for now to avoid them wherever possible and roll your own solution.
Maybe @astreet knows a few details - He is really great at fixing the whole Android / Yoga Rendering Stuff.
@K-Leon we haven't used any Modal component explicitly anywhere in our project. still issue persists.
Hey everyone, sorry you've been having these crashes. Without being able to look at a repro, this looks like a race condition between the UI thread and the native modules (background) thread.
onSizeChanged
here is enqueueing a runnable from the ui thread that references a shadow view by id on the native modules thread. Since the shadow thread 'runs ahead' of the UI thread (e.g. it has a newer state of the world than the UI thread), this isn't safe. By the time that code block runs, it's possible that an update from JS has already removed that view from the shadow hierarchy (a change which would then propagate to the native hierarchy on the UI thread). I'm not sure off hand what is causing onSizeChanged
to be called, so it could also be something else though -- e.g. the View in the hierarchy could not have an id set on it for some reason.
I'll try to see if I can get someone to look into it given the number of people affected.
Of course, a consistent repro would go a long way towards us being able to figure out the right fix :)
For me, I experience this crash randomly when I change the redux state of my app while transitioning to a new view. I experienced this crash using react native router flux and now with the new react navigation and react native versions 39-41.
I can't seem to consistently repro this crash, any advice on what I can try to make it consistent?
@astreet Hey, I can consistently reproduce this with https://github.com/Cooke/ReactNativeAndroidModalCrashBug/
Given this crash seems to occur for me when the keyboard doesn't finish collapsing/hiding in time during scene transition - do y'all think a viable workaround for me is to set a timeout on all of my scene transitions (I'm using https://reactnavigation.org/)?
@astreet Any news on this?
Maybe we should move this over to Canny, to gain visibility?
https://react-native.canny.io/feature-requests
That'll help the React team understand how many people are affected.
+1
I am experiencing the same issue. The only way I found to avoid the crash is wrapping the next action in a setTimeout(..., 1000)
to give time to the modal to be dismissed.
Sorry for the lack of update, I was able to use the verify what was going wrong, I should have a fix landed to master in the next day or two.
+1
Fix is in master now: https://github.com/facebook/react-native/commit/5873a228f41bca763c35c470375a9f3cb36f80ab
@astreet Unfortunately your fix is not working for me, I am still getting the null reference error. As you can see in the video below, one way I found to repro this crash is to submit a form immediately after updating it. Once submitted, the scene pops back.
EDIT: I can't reproduce this crash when the keyboard is hidden. It only seems to happen when the keyboard is up.
Here is a snapshot of my dependencies:
thanks so much!!
As per that commit, this particular NPE is no longer possible. Are you sure you have a version of RN with that commit in it?
If so, let's file a separate issue with a stack trace -- code that we can run on our end to repro the issue will also help us figure out the correct fix.
@astreet fair, I will do my due diligence and post my findings.
@astreet can we expect fix to be in rn 0.43?
@grabbou This should be pretty safe to merge, what release can we get this into do you think?
Yeah, I'll include it in next RC tomorrow.
I am using RN 0.42.3, but I am still getting this error randomly on application start.
@itcurves give a try with v0.43.0-rc.4
. I think that this release contains necessary patch as @grabbou stated.
I added a delay of 1 second before showing the infected view page, which solved the issue temporarily
I think it is related to react-native-router-flux
@cemo
I have not been able to run this release. I followed the documentation located here to upgrade to this release version you mentioned in your post, but when I try to do 'react-native run-android', this is what I get (see below). Is there any documentation for how to install one of these release versions?
@itcurves Do you have resolved this problem?
Is this issue already fixed in the latest release? Because I just checked my crashlytics and this issue seems to appear quite often.
So this commit is not in RN 0.43?
Looks like the commit didn't end up in 0.43 release by a mistake. I have
released a new version (0.43.3) along with some other smaller tweaks.
On Mon, 10 Apr 2017 at 07:16 tianxind notifications@github.com wrote:
So this commit is not in RN 0.43?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/facebook/react-native/issues/10845#issuecomment-292851648,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ACWcxkgG5jsmLZWEWvcEXF3xrKMfBofzks5rubsTgaJpZM4KuSyA
.
anyone confirm that this is fixed for RN 0.44?
Any update? We have the same issue with RN 0.41.2
RN 0.44 is ok?
Yes, .44 should be fine as it's listed in the release notes: https://github.com/facebook/react-native/releases/tag/v0.44.0
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
+1
+1
+1
+1
@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
.
Still happening in 0.49.5
The issue is still here, unfortunately.
React Native 0.55.4, 0.56.0
Android 8
Most helpful comment
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