Skip to content

Bug: NSException crash when using FilamentView with Expo SDK 54 + New Architecture #322

@migueljh

Description

@migueljh

Bug: NSException crash when using FilamentView with Expo SDK 54 + New Architecture

react-native-filament crashes with NSException when attempting to render a FilamentView in an Expo SDK 54 project with New Architecture enabled. The crash occurs in RNFAppleFilamentProxy::findFilamentView() when trying to find the native view component.

Environment

  • Expo SDK: 54.0.12
  • React Native: 0.81.4
  • react-native-filament: 1.8.0
  • react-native-worklets-core: 1.6.2
  • react-native-reanimated: 4.1.1
  • Platform: iOS (tested on simulator and device)
  • New Architecture: Enabled (newArchEnabled: true in app.json)

Configuration

babel.config.js:

module.exports = function (api) {
  api.cache(true);
  return {
    presets: ["babel-preset-expo"],
    plugins: [
      ["react-native-reanimated/plugin", { processNestedWorklets: true }],
    ],
  };
};

metro.config.js:

const { getDefaultConfig } = require("expo/metro-config");
const config = getDefaultConfig(__dirname);
config.resolver.assetExts = [...config.resolver.assetExts, "glb"];
module.exports = config;

app.json:

{
  "expo": {
    "newArchEnabled": true
  }
}

Steps to reproduce

  1. Create Expo SDK 54 project with development build
  2. Install react-native-filament and react-native-worklets-core
  3. Configure Babel and Metro as documented
  4. Run npx expo prebuild and pod install
  5. Create minimal FilamentView component (no model loading required):
import { View } from "react-native";
import { Camera, DefaultLight, FilamentScene, FilamentView } from "react-native-filament";

export default function MyScene() {
  return (
    <View style={{ flex: 1, backgroundColor: "#000" }}>
      <FilamentScene>
        <FilamentView style={{ flex: 1 }}>
          <DefaultLight />
          <Camera />
        </FilamentView>
      </FilamentScene>
    </View>
  );
}
  1. Run the app

Expected behavior

FilamentView should render successfully with the default camera and light.

Actual behavior

App crashes immediately when navigating to the screen with FilamentView.

Error logs

Console output:

[RNF/FilamentProxy]: Creating Engine... ✅
[RNF/HybridObject]: (MEMORY) Creating EngineWrapper (#1)... ✅
[RNF/HybridObject]: (MEMORY) Creating ChoreographerWrapper (#1)... ✅
[RNF/HybridObject]: (MEMORY) Creating ViewWrapper (#1)... ✅
[RNF/HybridObject]: (MEMORY) Creating CameraWrapper (#1)... ✅
[RNF/FilamentProxy]: Finding FilamentView #206...
[Error: Uncaught (in promise, id: 0) Error: Unknown non-std exception: NSException]

Xcode crash location (with Exception Breakpoint enabled):

File: RNFAppleFilamentProxy.mm, line 144

std::shared_ptr<FilamentView> AppleFilamentProxy::findFilamentView(int viewId) {
  UIView* anonymousView = [_surfacePresenter findComponentViewWithTag_DO_NOT_USE_DEPRECATED:viewId];
  
  if (anonymousView == nil) {
    throw std::runtime_error("Could not find view with given tag"); // ← CRASHES HERE
  }
  // ...
}

The _surfacePresenter (Fabric's RCTSurfacePresenter) cannot find the FilamentView native component by tag ID, returning nil and triggering the exception.

Workaround

Downgrading to Expo SDK 53 + React Native 0.79.5 + Reanimated 3.17.4 resolves the issue completely. The crash appears to be specific to the Fabric (New Architecture) implementation in newer versions.

Working configuration:

  • Expo SDK: 53.0.20
  • React Native: 0.79.5
  • react-native-reanimated: 3.17.4
  • All other config remains the same

Additional context

  • Compilation succeeds with 0 errors
  • All Filament wrappers are created successfully before the crash
  • The FilamentMetalView is created (visible in Xcode debugger variables)
  • The issue occurs even without loading any 3D models
  • Attempted fixes that didn't work:
    • Adding delay before mounting FilamentScene
    • Using collapsable={false} on FilamentView
    • Explicit dimensions on FilamentView
    • Different View wrapper configurations

This appears to be a timing or registration issue with how Fabric handles native view tags in Expo SDK 54+. The view exists but Fabric's findComponentViewWithTag_DO_NOT_USE_DEPRECATED cannot locate it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions