Skip to content

[SDK 52] React Native New Architecture (0.76.2) is throwing an error in the React Native view: TypeError: WeakMap key must be an Object #33117

Closed
@semsion

Description

@semsion

Minimal reproducible example

https://snack.expo.dev/@ionorox/vigorous-red-kiwi?platform=ios

What platform(s) does this occur on?

Android, iOS

Where did you reproduce the issue?

in a development build, in Expo Go

Summary

Description
React Native New Architecture (0.76.2) is throwing this error in the React Native view: TypeError: WeakMap key must be an Object.

This error has been observed on a physical Android device (Samsung A32 5G) (development build), Expo Go (Android via a physical device), Expo Go (Android via snack.expo.dev)), Expo Go (iOS via snack.expo.dev)). The issue doesn't appear to be present via snack.expo.dev for the web emulator.

Example Snack to illustrate the issue: https://snack.expo.dev/@ionorox/vigorous-red-kiwi?platform=android

Reproduction steps

  1. npx create-expo-app --template
  2. npx expo install expo-gl
  3. npm install three @react-three/fiber
  4. npm install @react-three/drei
  5. npm install @react-three/postprocessing postprocessing
  6. npx expo prebuild
  7. npx expo run:android

Error from the terminal:

((occasional) initial error)

Android Bundled 1447ms index.ts (1047 modules) (NOBRIDGE) LOG Bridgeless mode is enabled INFO 💡 JavaScript logs will be removed from Metro in React Native 0.77! Please use React Native DevTools as your default tool. Tip: Type j in the terminal to open (requires Google Chrome or Microsoft Edge). (NOBRIDGE) ERROR TypeError: Cannot read property 'trim' of undefined (NOBRIDGE) ERROR TypeError: Cannot read property 'trim' of undefined (NOBRIDGE) ERROR TypeError: Cannot read property 'trim' of undefined (NOBRIDGE) ERROR TypeError: Cannot read property 'trim' of undefined

(error after reloading app (~1-3 times))

Android Bundled 15484ms index.ts (1049 modules) (NOBRIDGE) LOG Bridgeless mode is enabled INFO 💡 JavaScript logs will be removed from Metro in React Native 0.77! Please use React Native DevTools as your default tool. Tip: Type j in the terminal to open (requires Google Chrome or Microsoft Edge). (NOBRIDGE) ERROR TypeError: WeakMap key must be an Object (NOBRIDGE) ERROR TypeError: WeakMap key must be an Object (NOBRIDGE) ERROR TypeError: WeakMap key must be an Object › Stopped server

The below is where the initial error, via a React Native view error call stack appears to points to, if the initial error presents itself, if not see the next error.
This initial error (if present) points towards the commented arrows in the code below, also inside of node_modules/three/build/three.cjs.

	function onFirstUse( self ) {

		// check for link errors
		if ( renderer.debug.checkShaderErrors ) {

			const programLog = gl.getProgramInfoLog( program ).trim(); // <<<<<<<<<<<<<
			// ...
	}

In this second, and sometimes only present React Native view error call stack, it appears to point towards the commented arrows in the code below, also inside of node_modules/three/build/three.cjs.

	function drawBuffers( renderTarget, framebuffer ) {

		let drawBuffers = defaultDrawbuffers;

		let needsUpdate = false;

		if ( renderTarget ) {

			drawBuffers = currentDrawbuffers.get( framebuffer );

			if ( drawBuffers === undefined ) {

				drawBuffers = [];
				currentDrawbuffers.set( framebuffer, drawBuffers ); // <<<<<<<<<<<<<

			}
			// ...
    }

Environment

  expo-env-info 1.2.1 environment info:
    System:
      OS: Linux 6.8 Ubuntu 24.04.1 LTS 24.04.1 LTS (Noble Numbat)
      Shell: 5.9 - /usr/bin/zsh
    Binaries:
      Node: 20.17.0 - ~/.nvm/versions/node/v20.17.0/bin/node
      npm: 10.8.2 - ~/.nvm/versions/node/v20.17.0/bin/npm
    npmPackages:
      expo: ~52.0.9 => 52.0.9 
      react: 18.3.1 => 18.3.1 
      react-native: 0.76.2 => 0.76.2 
    npmGlobalPackages:
      expo-cli: 6.3.12
    Expo Workflow: bare

Expo Doctor Diagnostics

➜  expo-rnbo-r3f-new-arch (master) ✗ npx expo-doctor@latest  
Enabled experimental React Native Directory checks. Unset the EXPO_DOCTOR_ENABLE_DIRECTORY_CHECK environment variable to disable this check.
✔ Check package.json for common issues
✔ Check Expo config for common issues
✔ Check native tooling versions
✔ Check for common project setup issues
✔ Check dependencies for packages that should not be installed directly
✔ Check npm/ yarn versions
✖ Check for app config fields that may not be synced in a non-CNG project
✔ Check if the project meets version requirements for submission to app stores
✔ Check for issues with Metro config
✔ Check Expo config (app.json/ app.config.js) schema
✔ Check for legacy global CLI installed locally
✔ Validate packages against React Native Directory package metadata
✔ Check that native modules do not use incompatible support packages
✔ Check that native modules use compatible support package versions for installed Expo SDK
✔ Check that packages match versions required by installed Expo SDK

Detailed check results:

This project contains native project folders but also has native configuration properties in app.json, indicating it is configured to use Prebuild. When the android/ios folders are present, if you don't run prebuild in your build pipeline, the following properties will not be synced: orientation, icon, userInterfaceStyle, splash, ios, android.

Metadata

Metadata

Assignees

Labels

needs reviewIssue is ready to be reviewed by a maintainer

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions