GLB Asset Loading Fails on Android with Undefined 'match' Error

GLB Asset Loading Fails on Android with Undefined ‘match’ Error

Environment

  • Expo Version: 51.0.39
  • React Native Version: 0.74.5
  • Platform: Android
  • Reproduction Method: expo run:android

Description

When attempting to load a compressed GLB file in a React Native Expo project, an error occurs on Android that prevents the asset from loading:

ERROR  Error: Could not load http://10.0.2.2:8082/assets/?unstable_path=.%2Fassets%2Fmodels/output.glb?platform=android&hash=80c4e5d9a2989da95b359e712a6197f5: Cannot read property 'match' of undefined

Steps to Reproduce

  1. Compress a GLB file using gltf-transform optimize input.glb output.glb --texture-compress webp
  2. Place the compressed GLB in the project’s assets folder
  3. Use the following code to load the asset:
    const AvaPath = Asset.fromModule(require('../../assets/models/output.glb')).uri;
    
    export function Ava({ words, replay, setReplay }) {
      const group = React.useRef();
      const { nodes, materials } = useLoader(GLTFLoader, AvaPath, (loader) => {
        loader.setMeshoptDecoder(MeshoptDecoder);
      });
    }
    
  4. Run the project with expo run:android

Expected Behavior

The GLB file should load successfully on Android, similar to how it works on web (expo start --web).

Actual Behavior

Loading fails with an undefined ‘match’ error, preventing the asset from being displayed.

Debugging Steps Attempted

  • Verified asset path
  • Confirmed web loading works correctly
  • Checked dependencies and versions

Relevant Dependencies

  • expo-asset: 10.0.10
  • expo-file-system: 17.0.1
  • meshoptimizer: 0.22.0
  • three: 0.169.0

Potential Areas of Investigation

  1. Asset loading mechanism differences between web and Android
  2. Compatibility of compressed GLB with React Native asset system
  3. Potential issues with Asset.fromModule() on Android

Additional Notes

  • The same GLB file works correctly when running on web
  • File was compressed from 1GB to 20MB using gltf-transform

Reproducibility

✓ Consistently Reproducible

Request

Could maintainers provide guidance on:

  • Proper asset loading for compressed GLB files in React Native/Expo
  • Potential workarounds for this loading issue
  • Known compatibility issues with GLB assets

/cc @expo/expo @react-three/fiber

I’m a maintainer of GLTFLoader, but in a volunteer capacity I have no bandwidth to investigate support specific to React Native Expo. I would recommend filing an issue at…

… or perhaps asking on the Poimandres discord server. It’s likely someone there would have experience with glTF loading in React Native, or perhaps know some expected limitations.

1 Like

Thank you for this…