maps icon indicating copy to clipboard operation
maps copied to clipboard

[Bug]: Random error: “Mapbox [error] ViewTagResolver | view: null found with tag: xxxx but it's either null or not the correct type”.

Open two3d opened this issue 10 months ago • 25 comments

Mapbox Implementation

Mapbox

Mapbox Version

10.1.33

React Native Version

0.76.6

Platform

Android

@rnmapbox/maps version

10.1.33

Standalone component to reproduce

Index page (for navigation test : index <-> map):

import React from 'react';
import {View,Text} from 'react-native';
import { Link } from 'expo-router';

export default function EventList() {
  return (
      <View>
        <Link href={{pathname: "/map"}}>
          <Text>TEST MAP</Text>
        </Link>
      </View>
  );
}

Map page

import React from 'react';

// importa Mapbox and set token
import Mapbox from '@rnmapbox/maps';
// (token is defined here, but commented for your rule) Mapbox.setAccessToken('xxxxxxxxxxxxxxx');

import { MapView } from '@rnmapbox/maps';
import { View } from 'react-native';


export default function Map() {

  return (
    <View style={{flex: 1}}>
      <MapView style={{flex: 1}}/>
    </View>
  );

};

Observed behavior and steps to reproduce

The error “Mapbox [error] ViewTagResolver | view: null found with tag: xxxx but it's either null or not the correct type” appears randomly as soon as you arrive on the map, sometimes yes, sometimes no.

Note that the “with tag” increases as the error is encountered (may help debugging).

See captures taken one by one. And the console for more details.

After a round-trip index-map Image After a round-trip index-map Image After a round-trip index-map Image After a round-trip index-map Image After a round-trip index-map Image

Image

Expected behavior

Do not display this error.

Notes / preliminary analysis

The “with tag: xxx” increases as the error is encountered.

If the error doesn't appear, go to the map, zoom in or out, then back to the index, then back to the map.

It can take 4 or 5 round trips before there's an error, sometimes 0, sometimes more.

My package.json :

{
  "name": "projectname",
  "main": "expo-router/entry",
  "version": "1.0.1",
  "scripts": {
    "start": "expo start",
    "reset-project": "node ./scripts/reset-project.js",
    "android": "expo run:android",
    "ios": "expo run:ios",
    "web": "expo start --web",
    "test": "jest --watchAll",
    "lint": "expo lint"
  },
  "jest": {
    "preset": "jest-expo"
  },
  "dependencies": {
    "@expo/vector-icons": "^14.0.2",
    "@react-native-async-storage/async-storage": "1.23.1",
    "@react-navigation/bottom-tabs": "^7.2.0",
    "@react-navigation/native": "^7.0.14",
    "@rnmapbox/maps": "^10.1.33",
    "@tanstack/react-query": "^4.36.1",
    "axios": "^1.7.9",
    "expo": "~52.0.27",
    "expo-blur": "~14.0.3",
    "expo-checkbox": "~4.0.1",
    "expo-font": "~13.0.3",
    "expo-image-picker": "~16.0.4",
    "expo-linear-gradient": "~14.0.2",
    "expo-linking": "~7.0.5",
    "expo-router": "~4.0.17",
    "expo-splash-screen": "~0.29.21",
    "expo-status-bar": "~2.0.1",
    "expo-system-ui": "~4.0.7",
    "react": "18.3.1",
    "react-dom": "18.3.1",
    "react-native": "^0.76.6",
    "react-native-gesture-handler": "~2.20.2",
    "react-native-reanimated": "~3.16.1",
    "react-native-safe-area-context": "4.12.0",
    "react-native-screens": "~4.4.0",
    "react-native-web": "~0.19.13",
    "react-native-webview": "13.12.5"
  },
  "devDependencies": {
    "@babel/core": "^7.25.2",
    "@react-native-community/cli": "^15.1.3",
    "@types/jest": "^29.5.12",
    "@types/react": "~18.3.12",
    "@types/react-test-renderer": "^18.3.0",
    "jest": "^29.2.1",
    "jest-expo": "~52.0.3",
    "react-test-renderer": "18.3.1",
    "typescript": "^5.3.3"
  },
  "private": true
}

My device :

Android Emulator - OUKITEL_API_31:5554

Additional links and references

No response

two3d avatar Jan 28 '25 21:01 two3d

same issue in cli, happening on android only, not ios

torodebout avatar Jan 29 '25 13:01 torodebout

I see that the version returned by the command: “npm @rnmapbox/maps -v” is 11.0.0. My package.json shows 10.1.33

Perhaps this has something to do with the error?

two3d avatar Jan 29 '25 13:01 two3d

I see that the version returned by the command: “npm @rnmapbox/maps -v” is 11.0.0. My package.json shows 10.1.33

Perhaps this has something to do with the error?

No that shows your npm version, not your rnmapbox. You can use npm list @rnmapbox/maps to see rnmapbox version. Anyway, I am having the same issue. Appeared after enabling new architecture.

iGrits avatar Feb 03 '25 05:02 iGrits

No that shows your npm version, not your rnmapbox. You can use npm list @rnmapbox/maps to see rnmapbox version. Anyway, I am having the same issue. Appeared after enabling new architecture.

@rnmapbox/[email protected] Thanks, I've updated my post 👍

two3d avatar Feb 03 '25 10:02 two3d

Any updates on this issue?

sabuhiteymurov avatar Feb 13 '25 08:02 sabuhiteymurov

I'm hiding the errors for now:

import {LogBox} from "react-native";

LogBox.ignoreLogs([ //Mapbox errors 'Mapbox [error] ViewTagResolver | view:' ]);

two3d avatar Feb 13 '25 08:02 two3d

Any updates ? I'm also experiencing the same issue.

alternacrow avatar Mar 14 '25 06:03 alternacrow

Any updates?

hassanad94 avatar Mar 20 '25 14:03 hassanad94

Hello guys.. Has there been any fix for this issue..

Sir-ct avatar Mar 28 '25 03:03 Sir-ct

as @two3d mentionned, temporary solution is to suppress the error/warning

import { LogBox } from 'react-native'; LogBox.ignoreLogs(['ViewTagResolver']);

torodebout avatar Apr 08 '25 14:04 torodebout

Anyone know how to fix this issue?

import { LogBox } from 'react-native';
LogBox.ignoreLogs(['ViewTagResolver']);

dont help

shahzeb79 avatar Apr 23 '25 17:04 shahzeb79

Anyone know how to fix this issue?

import { LogBox } from 'react-native';
LogBox.ignoreLogs(['ViewTagResolver']);

dont help

Is not this ViewTagResolver but Mapbox [error] ViewTagResolver | view: (what you want to hide has to start with exactly that).

two3d avatar Apr 23 '25 18:04 two3d

but even ignoreLogs, app crashes in production due to this issue.

any one found solution yet?

shahzeb79 avatar May 01 '25 14:05 shahzeb79

Just found the view null that cause the error in this file

node_modules@rnmapbox\maps\src\components\MapView.tsx

in the render() function, just before the return :

if (mapView == null) {
  mapView = (
    <RNMBXMapView {...props} {...callbacks}>
      {this.props.children}
    </RNMBXMapView>
  )
}

return (
  <View
    onLayout={this._onLayout}
    style={this.props.style}
    testID={mapView ? undefined : this.props.testID}
  >
    {mapView}
  </View>
);

Med-Li-Jr avatar May 04 '25 16:05 Med-Li-Jr

any fix for this? @Med-Li-Jr how to solve this? I see in .37 it looks like this:

let mapView = null; if (this.state.isReady) { if (props._nativeImpl) { mapView = <props._nativeImpl {...props} {...callbacks} />; } else { mapView = ( <RNMBXMapView {...props} {...callbacks}> {this.props.children} </RNMBXMapView> ); } }

LukasB-DEV avatar May 05 '25 13:05 LukasB-DEV

@LukasB-DEV , just add this before the return keyword

      if (mapView == null) {
        mapView = (
          <RNMBXMapView {...props} {...callbacks}>
            {this.props.children}
          </RNMBXMapView>
        )
      }

So your code should be like :

          let mapView = null;
        if (this.state.isReady) {
          if (props._nativeImpl) {
            mapView = <props._nativeImpl {...props} {...callbacks} />;
          } else {
            mapView = (
            <RNMBXMapView {...props} {...callbacks}>
                {this.props.children}
              </RNMBXMapView>
            );
          }
        }
  
      // New Lines start here
      if (mapView == null) {
        mapView = (
          <RNMBXMapView {...props} {...callbacks}>
            {this.props.children}
          </RNMBXMapView>
        )
      }
      // New Lines end here
  
            
      return (
        <View
          onLayout={this._onLayout}
          style={this.props.style}
          testID={mapView ? undefined : this.props.testID}
        >
          {mapView}
        </View>
      );                    

Med-Li-Jr avatar May 05 '25 22:05 Med-Li-Jr

@Med-Li-Jr thanks! Can you please create a PR?

cixio avatar May 05 '25 23:05 cixio

// New Lines start here if (mapView == null) { mapView = ( <RNMBXMapView {...props} {...callbacks}> {this.props.children} </RNMBXMapView> ) } // New Lines end here

Works. Thanks!

LukasB-DEV avatar May 06 '25 12:05 LukasB-DEV

@LukasB-DEV , just add this before the return keyword

      if (mapView == null) {
        mapView = (
          <RNMBXMapView {...props} {...callbacks}>
            {this.props.children}
          </RNMBXMapView>
        )
      }

So your code should be like :

          let mapView = null;
        if (this.state.isReady) {
          if (props._nativeImpl) {
            mapView = <props._nativeImpl {...props} {...callbacks} />;
          } else {
            mapView = (
            <RNMBXMapView {...props} {...callbacks}>
                {this.props.children}
              </RNMBXMapView>
            );
          }
        }
  
      // New Lines start here
      if (mapView == null) {
        mapView = (
          <RNMBXMapView {...props} {...callbacks}>
            {this.props.children}
          </RNMBXMapView>
        )
      }
      // New Lines end here
  
            
      return (
        <View
          onLayout={this._onLayout}
          style={this.props.style}
          testID={mapView ? undefined : this.props.testID}
        >
          {mapView}
        </View>
      );                    

@Med-Li-Jr , thanks for this. A question please;

Does this mean each time I delete a node_modules, I have to add the fix? If so, is there any workaround of a permanent solution?

Crawford30 avatar May 10 '25 15:05 Crawford30

@LukasB-DEV , just add this before the return keyword

      if (mapView == null) {
        mapView = (
          <RNMBXMapView {...props} {...callbacks}>
            {this.props.children}
          </RNMBXMapView>
        )
      }

So your code should be like :

          let mapView = null;
        if (this.state.isReady) {
          if (props._nativeImpl) {
            mapView = <props._nativeImpl {...props} {...callbacks} />;
          } else {
            mapView = (
            <RNMBXMapView {...props} {...callbacks}>
                {this.props.children}
              </RNMBXMapView>
            );
          }
        }
  
      // New Lines start here
      if (mapView == null) {
        mapView = (
          <RNMBXMapView {...props} {...callbacks}>
            {this.props.children}
          </RNMBXMapView>
        )
      }
      // New Lines end here
  
            
      return (
        <View
          onLayout={this._onLayout}
          style={this.props.style}
          testID={mapView ? undefined : this.props.testID}
        >
          {mapView}
        </View>
      );                    

@Med-Li-Jr , thanks for this. A question please;

Does this mean each time I delete a node_modules, I have to add the fix? If so, is there any workaround of a permanent solution?

You can use npm patch-package if you use npm. Yarn also has such a solution

LukasB-DEV avatar May 11 '25 10:05 LukasB-DEV

@LukasB-DEV , just add this before the return keyword

      if (mapView == null) {
        mapView = (
          <RNMBXMapView {...props} {...callbacks}>
            {this.props.children}
          </RNMBXMapView>
        )
      }

So your code should be like :

          let mapView = null;
        if (this.state.isReady) {
          if (props._nativeImpl) {
            mapView = <props._nativeImpl {...props} {...callbacks} />;
          } else {
            mapView = (
            <RNMBXMapView {...props} {...callbacks}>
                {this.props.children}
              </RNMBXMapView>
            );
          }
        }
  
      // New Lines start here
      if (mapView == null) {
        mapView = (
          <RNMBXMapView {...props} {...callbacks}>
            {this.props.children}
          </RNMBXMapView>
        )
      }
      // New Lines end here
  
            
      return (
        <View
          onLayout={this._onLayout}
          style={this.props.style}
          testID={mapView ? undefined : this.props.testID}
        >
          {mapView}
        </View>
      );                    

@Med-Li-Jr , thanks for this. A question please;

Does this mean each time I delete a node_modules, I have to add the fix? If so, is there any workaround of a permanent solution?

@Crawford30 yes it seems so, 'cause the error comes from one of the file in the folder node_modules. As @LukasB-DEV said, you can use patch-package to do it auto instead of manual

here is a temp patch file to use, until there is an official one : @rnmapbox+ViewTagResolver+error+null+TEMP.patch

Med-Li-Jr avatar May 11 '25 23:05 Med-Li-Jr

Issues with @rnmapbox/maps and React Native 0.79.0

I'm getting multiple warnings and errors when using @rnmapbox/maps@^10.1.39 with React Native 0.79.0:

Errors:

new NativeEventEmitter() was called with a non-null argument without the required addListener method. Error Component Stack:

new NativeEventEmitter() was called with a non-null argument without the required removeListeners method. Error Component Stack:

Warnings:

Mapbox [error] ViewTagResolver | view: null found with tag: 1184 but it's either null or not the correct type

Environment:

"react-native": "0.79.0",
"@rnmapbox/maps": "^10.1.39"

Has anyone else experienced these issues? Is there a known fix or workaround?

FernandoAOborges avatar May 29 '25 19:05 FernandoAOborges

To stop the error from occurring, you can add the property newArchEnabled=false in the android/gradle.properties file. If you're using Expo, you can do this in the app.json file:

This is not a viable long-term solution. Setting newArchEnabled=false works as a temporary workaround, but it's not a proper fix. The best approach is to wait for an official update from the maintainers, as disabling the new architecture means losing potential performance improvements and future enhancements. I believe it's better to be patient and allow the development team to address this properly.

FernandoAOborges avatar Jun 17 '25 11:06 FernandoAOborges

I have the same exact issue. Waiting for a fix...

MarcAntoineCarrier28 avatar Jun 17 '25 19:06 MarcAntoineCarrier28

Same over here

javier-sauma-rocketlab avatar Jun 19 '25 01:06 javier-sauma-rocketlab

+1

DavidAmyot avatar Jun 20 '25 15:06 DavidAmyot

+1

correafederico25 avatar Jun 20 '25 19:06 correafederico25

+1

rodolforamos avatar Jun 22 '25 18:06 rodolforamos

Even with this error are you guys able to use mapbox in production build? I'm having issues in prod, when its dev build its working but when its prod the hole app crashes when it comes into Mapbox view

MariuzM avatar Jun 25 '25 07:06 MariuzM

Even with this error are you guys able to use mapbox in production build? I'm having issues in prod, when its dev build its working but when its prod the hole app crashes when it comes into Mapbox view

+1

drogon98 avatar Jun 25 '25 09:06 drogon98