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

Exception in HostObject::get for prop 'RNCGeolocation': java.lang.NullPointerException: Null context is not permitted., js engine: hermes #206

Closed
petrlz63 opened this issue Oct 19, 2022 · 13 comments · Fixed by #207
Labels
bug Something isn't working

Comments

@petrlz63
Copy link

petrlz63 commented Oct 19, 2022

Environment

production

Platforms

Android

Versions

  • Android: 8-13
  • react-native-geolocation: 3.x
  • react-native: 0.69.5
  • react: 18

Description

After update react-native-geolocation to 3 (tried all 3.x versions) we are getting this error on multiple android devices:
Error: Exception in HostObject::get for prop 'RNCGeolocation': java.lang.NullPointerException: Null context is not permitted., js engine: hermes

Reproducible Demo

Sadly we can't reproduce it on our own test devices :/

@petrlz63 petrlz63 added the bug Something isn't working label Oct 19, 2022
@michalchudziak
Copy link
Owner

Could you provide me with more detailed environment info, or ideally with a minimal repro project?

@jplandry908
Copy link
Contributor

jplandry908 commented Oct 20, 2022

I'm having the same issue and am unable to figure out the root cause. I'm on react-native 0.70.2. All I did was upgrade from react-native-geolocation v2.1.0 to v3 (tried 3.0.0, 3.0.1, and 3.0.2) and seeing this crash. It appears to only show up in Android Release mode. I'm not seeing any issues on iOS (debug or release) or Android (debug). It was not noticed until deployed for distribution, but I am also able to detect it in the emulator if I change it to release.

No other code changes were made and if I download back to v2.1.0 the error goes away.

Fatal Exception: com.facebook.react.common.JavascriptException: Error: Exception in HostObject::get for prop 'RNCGeolocation': java.lang.NullPointerException: Null context is not permitted., js engine: hermes, stack:
anonymous@1:712046
loadModuleImplementation@1:71965
guardedLoadModule@1:71513
metroRequire@1:71141
anonymous@1:710866
loadModuleImplementation@1:71965
guardedLoadModule@1:71513
metroRequire@1:71141
anonymous@1:709995
loadModuleImplementation@1:71965
guardedLoadModule@1:71513
metroRequire@1:71141
anonymous@1:705118
loadModuleImplementation@1:71965
guardedLoadModule@1:71513
metroRequire@1:71141
anonymous@1:594601
loadModuleImplementation@1:71965
guardedLoadModule@1:71513
metroRequire@1:71141
anonymous@1:592109
loadModuleImplementation@1:71965
guardedLoadModule@1:71513
metroRequire@1:71141
anonymous@1:78353
loadModuleImplementation@1:71965
guardedLoadModule@1:71470
metroRequire@1:71141
global@1:70716

   at com.facebook.react.modules.core.ExceptionsManagerModule.reportException(ExceptionsManagerModule.java:72)
   at java.lang.reflect.Method.invoke(Method.java)
   at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:372)
   at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:188)
   at com.facebook.jni.NativeRunnable.run(NativeRunnable.java)
   at android.os.Handler.handleCallback(Handler.java:938)
   at android.os.Handler.dispatchMessage(Handler.java:99)
   at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:27)
   at android.os.Looper.loopOnce(Looper.java:201)
   at android.os.Looper.loop(Looper.java:288)
   at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:228)
   at java.lang.Thread.run(Thread.java:920)

@jplandry908
Copy link
Contributor

jplandry908 commented Oct 20, 2022

HI @michalchudziak. This appears to be caused when Hermes is enabled. I took a look at your example and it Hermes is set to false and the new architecture is set to true. My project has Hermes set to true and the new architecture set to false. I disabled Hermes and the app was able to launch successfully.

@michalchudziak
Copy link
Owner

HI @michalchudziak. This appears to be caused when Hermes is enabled. I took a look at your example and it Hermes is set to false and the new architecture is set to true. My project has Hermes set to true and the new architecture set to false. I disabled Hermes and the app was able to launch successfully.

That's a good lead, I will test it out today. Thanks

@michalchudziak
Copy link
Owner

I just tried out the example app with Hermes enabled and I can't reproduce the issue. Could you provide me with a minimal repro project? I will be happy to fix the issue as soon as I'm able to reproduce it.

@michalchudziak
Copy link
Owner

Also, more info about the affected devices/build flavor, etc will be helpful.

@jplandry908
Copy link
Contributor

Let me see if I can figure out what is different between my solution and your example. I'll do some more troubleshooting and get back to you.

@jplandry908
Copy link
Contributor

@michalchudziak. I was able to reproduce this issue with a clean install by following the following steps.

1. Create new react-native app
react-native init test --version 0.70.2

2. Install geolocation module within new app
npm install @react-native-community/geolocation

3. Add geolocation import to default 'App.js' file
import Geolocation from '@react-native-community/geolocation';

4. Run using Build Variant 'release' (not debug)

Every time you attempt to launch the app, it crashes every time.

@michalchudziak
Copy link
Owner

@jplandry908 Can you tell me which device you use? I followed these steps on the Pixel emulator & physical Samsung S10 and everything works well. Maybe it's specific to some group of devices?

@jplandry908
Copy link
Contributor

jplandry908 commented Oct 27, 2022

Hi @michalchudziak. How strange. I was able to reproduce the crash on every emulator I tried. Pixel 5 (API 31), Pixel 4 (API 29), & Pixel 3 (API 30) are some examples. Also, when I only update this module on my production app, it works fine in iOS and Android DEBUG locally but if I test on the release variant it fails. I detected this (since I rarely change my local variant to release) when I pushed it to Google Play store and it failed all 10 of their random tests using random devices. Let me package up my test project for you.

@petrlz63 - Yo you have any other information? It sounds like you are experiencing the same issue when trying to upgrade your app.

UPDATE: This link will be valid for 48 hours. It was built using the steps outlined above. I also removed the IOS folder to reduce the size.
https://sendanywhe.re/P4FT62SS

@michalchudziak
Copy link
Owner

@jplandry908 Thank you a lot, I'm able to reproduce and fix the issue. I'll ship the new version soon :)

@michalchudziak
Copy link
Owner

Fixed in 3.0.3 release

@jplandry908
Copy link
Contributor

Thanks @michalchudziak. I can confirm that the issue appears to have been fixed in the v3.0.3 release. I appreciate your support!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants