Skip to content

[Android] Fix crash with RN Screens FormSheet#4243

Open
m-bert wants to merge 1 commit into
mainfrom
@mbert/screens-dimming
Open

[Android] Fix crash with RN Screens FormSheet#4243
m-bert wants to merge 1 commit into
mainfrom
@mbert/screens-dimming

Conversation

@m-bert
Copy link
Copy Markdown
Collaborator

@m-bert m-bert commented Jun 8, 2026

Description

DimmingView from React Native Screens implements ReactCompoundViewGroup, which implements ReactCompoundView. However, this component is managed entirely by Screens, so reactTagForTouch throws when called. This causes crash when Orchestrator tries to obtain tag (see here).

To prevent that we add try/catch block. Note that simply checking for ReactViewGroup wouldn't work, as Text is not ReactViewGroup. There are also other components in Screens, which do not inherit from ReactViewGroup, but from ViewGroup instead.

Fixes #4237

Test plan

expo-example app (Nested Text and SVG)

The following code:
import { NavigationContainer } from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import { Button, Platform, StyleSheet, Text, View } from 'react-native';
import { GestureHandlerRootView } from 'react-native-gesture-handler';
import { enableScreens } from 'react-native-screens';

enableScreens(true);

const Stack = createNativeStackNavigator();

function HomeScreen({ navigation }) {
  return (
    <View style={styles.screen}>
      <View style={styles.card}>
        <Text style={styles.title}>Android formSheet repro</Text>
        <Text style={styles.body}>
          This app uses Expo 56 bare workflow with react-native-screens 4.25.2.
          Press the button to present a native-stack screen with presentation
          set to formSheet.
        </Text>
        <Button
          title="Open form sheet"
          onPress={() => navigation.navigate('FormSheet')}
        />
      </View>
    </View>
  );
}

function FormSheetScreen({ navigation }) {
  return (
    <View style={styles.sheet}>
      <Text style={styles.sheetTitle}>Form sheet content</Text>
      <Text style={styles.body}>
        This is a modal form sheet presented by react-native-screens through
        React Navigation native stack on {Platform.OS}.
      </Text>
      <View style={styles.spacer} />
      <Button title="Close sheet" onPress={() => navigation.goBack()} />
    </View>
  );
}

export default function App() {
  return (
    <GestureHandlerRootView style={styles.root}>
      <NavigationContainer>
        <Stack.Navigator>
          <Stack.Screen
            name="Home"
            component={HomeScreen}
            options={{ title: 'FormSheet Repro' }}
          />
          <Stack.Screen
            name="FormSheet"
            component={FormSheetScreen}
            options={{
              title: 'Form Sheet',
              presentation: 'formSheet',
              sheetAllowedDetents: [0.45, 0.8],
              sheetCornerRadius: 24,
              sheetGrabberVisible: true,
            }}
          />
        </Stack.Navigator>
      </NavigationContainer>
    </GestureHandlerRootView>
  );
}

const styles = StyleSheet.create({
  root: {
    flex: 1,
  },
  screen: {
    flex: 1,
    backgroundColor: '#f4f6fb',
    alignItems: 'center',
    justifyContent: 'center',
    padding: 24,
  },
  card: {
    width: '100%',
    maxWidth: 420,
    borderRadius: 24,
    backgroundColor: '#fff',
    padding: 24,
    shadowColor: '#000',
    shadowOpacity: 0.1,
    shadowRadius: 18,
    elevation: 4,
  },
  title: {
    marginBottom: 12,
    color: '#111827',
    fontSize: 28,
    fontWeight: '700',
  },
  sheet: {
    flex: 1,
    justifyContent: 'center',
    padding: 24,
    backgroundColor: '#fff',
  },
  sheetTitle: {
    marginBottom: 12,
    color: '#111827',
    fontSize: 24,
    fontWeight: '700',
  },
  body: {
    marginBottom: 24,
    color: '#4b5563',
    fontSize: 16,
    lineHeight: 24,
  },
  spacer: {
    height: 12,
  },
});

Copilot AI review requested due to automatic review settings June 8, 2026 11:27
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR prevents an Android crash when React Native Screens’ DimmingView (and potentially other ReactCompoundView implementations) throws from reactTagForTouch, by safely handling that exception during gesture handler extraction.

Changes:

  • Wraps ReactCompoundView.reactTagForTouch(x, y) in a try/catch to avoid propagating IllegalStateException.
  • Skips looking up handlers by the returned tag when the tag cannot be obtained (exception case), preventing the orchestrator from crashing.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[V3] Android crash with RN Screens form sheet backdrop

3 participants