rnmapbox / maps

A Mapbox react native module for creating custom maps
MIT License
2.21k stars 836 forks source link

[Bug]: NullPointerException com.rnmapbox.rnmbx.utils.ViewTagResolver #3343

Open JClackett opened 8 months ago

JClackett commented 8 months ago

Mapbox Implementation

Mapbox

Mapbox Version

11.0.0

Platform

Android

@rnmapbox/maps version

10.1.5

expo version

50.0.3

Standalone component to reproduce

import React from 'react';
import {
  MapView,
  ShapeSource,
  LineLayer,
  Camera,
} from '@rnmapbox/maps';

const aLine = {
  type: 'LineString',
  coordinates: [
    [-74.00597, 40.71427],
    [-74.00697, 40.71527],
  ],
};

class BugReportExample extends React.Component {
  render() {
    return (
      <MapView style={{flex: 1}}>
        <Camera centerCoordinate={[-74.00597, 40.71427]} zoomLevel={14} />
        <ShapeSource id="idStreetLayer" shape={aLine}>
          <LineLayer id="idStreetLayer" />
        </ShapeSource>
      </MapView>
    );
  }
}

Observed behavior and steps to reproduce

Only when deployed, the app sometimes crashes on android with this:

java.lang.NullPointerException: null
    at com.rnmapbox.rnmbx.utils.ViewTagResolver.getManager(ViewTagResolver.kt:51)
    at com.rnmapbox.rnmbx.utils.ViewTagResolver.withViewResolved$lambda$4(ViewTagResolver.kt:58)
    at com.rnmapbox.rnmbx.utils.ViewTagResolver.$r8$lambda$ZFXWzquiK28lSR5tbH0BihabahM
    at com.rnmapbox.rnmbx.utils.ViewTagResolver$$ExternalSyntheticLambda0.run
    at android.os.Handler.handleCallback(Handler.java:942)
    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:226)
    at android.os.Looper.loop(Looper.java:313)
    at android.app.ActivityThread.main(ActivityThread.java:8757)
    at java.lang.reflect.Method.invoke(Method.java)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)

Expected behavior

Not crash

Notes / preliminary analysis

Really not sure, after the app crashed and reopening it works again

Additional links and references

No response

mfazekas commented 8 months ago

See https://github.com/rnmapbox/maps/issues/3243, can't really do much with it without a way to reproduce the issue

jacobhummel commented 7 months ago

@mfazekas We started seeing this issue a lot in production after upgrading Expo 48 -> 49 and @rnmapbox/maps 10.0.10 -> 10.1.8 simultaneously (so I can't say 100% it's just the mapbox change). Our app crash rate went from under 2% to around 8% from this one crash. It seems to intermittently occur when a user is using the app for a while in the background and re-opens it. It crashes immediately on app re-open.

gretzky commented 6 months ago

We're experiencing the same issue. While it's very hard to reproduce- it seems like this issue is related.

FrederickEngelhardt commented 1 month ago

Google play console testing shows it on a Motorola api 30. All of my devices on api34 do not have this issue and this is on a Rn74 app.

Seems to happen immediately on launch of the map. The error was caught in google's automated testing pipeline.

For context, my app launches with the map almost immediately after requesting for tileserver urls and related data.

My app does not include expo. So pretty sure it's unrelated to expo, but could be related to react-native version and how modules are initialized.

Screenshot_20240809_172332_Chrome.jpg

FATAL EXCEPTION: main
Process: <yourapp>, PID: 19862
java.lang.NullPointerException
    at com.rnmapbox.rnmbx.components.mapview.y.H0(SourceFile:27)
    at com.rnmapbox.rnmbx.components.mapview.NativeMapViewModule$n.a(SourceFile:12)
    at com.rnmapbox.rnmbx.components.mapview.NativeMapViewModule$n.invoke(SourceFile:3)
    at ha.r.h(SourceFile:34)
    at ha.r.a(SourceFile:1)
    at ha.p.run(SourceFile:1)
    at android.os.Handler.handleCallback(Handler.java:938)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(SourceFile:1)
    at android.os.Looper.loop(Looper.java:240)
    at android.app.ActivityThread.main(ActivityThread.java:8000)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:603)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947) 
Gp2mv3 commented 2 weeks ago

Hello, I see the same error in my Android vitals. I'm using RN 0.74.0 and rnMapbox 10.1.29.

Maybe this trace can help too:

Exception java.lang.NullPointerException:
  at com.rnmapbox.rnmbx.components.camera.CameraUpdateQueue.execute (CameraUpdateQueue.kt:62)
  at com.rnmapbox.rnmbx.components.camera.RNMBXCamera.updateCamera (RNMBXCamera.kt:205)
  at com.rnmapbox.rnmbx.components.camera.RNMBXCamera.access$setHasSentFirstRegion$p (RNMBXCamera.kt:41)
  at com.rnmapbox.rnmbx.components.camera.RNMBXCamera.access$updateCamera (RNMBXCamera.kt:41)
  at com.rnmapbox.rnmbx.components.camera.RNMBXCamera$addToMap$1.invoke (RNMBXCamera.kt:104)
  at com.rnmapbox.rnmbx.components.camera.RNMBXCamera$addToMap$1.invoke (RNMBXCamera.kt:101)
  at com.rnmapbox.rnmbx.components.mapview.RNMBXLifeCycle.afterAttachFromLooper (RNMBXMapView.kt:178)
  at com.rnmapbox.rnmbx.components.mapview.RNMBXMapView.onAttachedToWindow$lambda$26 (RNMBXMapView.kt:1479)
  at android.os.Handler.handleCallback (Handler.java:958)
  at android.os.Handler.dispatchMessage (Handler.java:99)
  at android.os.Looper.loopOnce (Looper.java:230)
  at android.os.Looper.loop (Looper.java:319)
  at android.app.ActivityThread.main (ActivityThread.java:8918)
  at java.lang.reflect.Method.invoke
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:608)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1103)

Any clue ?