-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
ReactContext#getCurrentActivity() is null in createViewInstance() #9310
Comments
|
Is there any updates? Still null for me |
…ntext Summary: `ThemedReactContext` wraps the actual `ReactContext` but doesn't actually receive any lifecycle events, which would set `mCurrentActivity`, so that's always stuck as `null`. To fix, we override `has/getCurrentActivity` and forward the call to the wrapped context, which actually has the correct lifecycle status. Fixes issue #9310 on github. Reviewed By: mkonicek Differential Revision: D3703005 fbshipit-source-id: 363e87ac91d50516899b413e823d5312cbb807f4
Fixed in 96e4121. |
Is this going to be released in 0.32 or only in 0.33-rc? |
It will probably be in the next RC. |
…ntext Summary: `ThemedReactContext` wraps the actual `ReactContext` but doesn't actually receive any lifecycle events, which would set `mCurrentActivity`, so that's always stuck as `null`. To fix, we override `has/getCurrentActivity` and forward the call to the wrapped context, which actually has the correct lifecycle status. Fixes issue facebook#9310 on github. Reviewed By: mkonicek Differential Revision: D3703005 fbshipit-source-id: 363e87ac91d50516899b413e823d5312cbb807f4
…ntext Summary: `ThemedReactContext` wraps the actual `ReactContext` but doesn't actually receive any lifecycle events, which would set `mCurrentActivity`, so that's always stuck as `null`. To fix, we override `has/getCurrentActivity` and forward the call to the wrapped context, which actually has the correct lifecycle status. Fixes issue facebook#9310 on github. Reviewed By: mkonicek Differential Revision: D3703005 fbshipit-source-id: 363e87ac91d50516899b413e823d5312cbb807f4
Do I have to wait for 0.33 or is there another way to get an Activity in a view? |
Could this also cause a crash in Lines 123 to 126 in e70d1db
|
Summary: We're seeing a lot of crashes from `PermissionsModule` not being able to access the current activity, mentioned in #10009 and here: #9310 (comment) As far as I can tell, there is no way to ensure the Activity exists since the `ReactContext` holds a `WeakReference` to the current Activity and it appears that the lifecycle calls are happening in the right order (so not the same as #9310). This will at least allow people to catch the error in JS and update the UI or try again as opposed to crashing the app. I'm working on some bigger changes in #10221 but this is a smaller change and important to get fixed I think. Closes #10351 Differential Revision: D4010242 fbshipit-source-id: 7a76973bb2b3e45817d4283917740c89a10ec0b0
Summary: We're seeing a lot of crashes from `PermissionsModule` not being able to access the current activity, mentioned in #10009 and here: #9310 (comment) As far as I can tell, there is no way to ensure the Activity exists since the `ReactContext` holds a `WeakReference` to the current Activity and it appears that the lifecycle calls are happening in the right order (so not the same as #9310). This will at least allow people to catch the error in JS and update the UI or try again as opposed to crashing the app. I'm working on some bigger changes in #10221 but this is a smaller change and important to get fixed I think. Closes #10351 Differential Revision: D4010242 fbshipit-source-id: 7a76973bb2b3e45817d4283917740c89a10ec0b0
See discussion on #8661 for more info, we should never create views before we have an attached activity. This means we can either move the call to
startApplication
toonResume
or set the current activity inonCreate
.The text was updated successfully, but these errors were encountered: