Skip to content
This repository was archived by the owner on May 31, 2025. It is now read-only.
This repository was archived by the owner on May 31, 2025. It is now read-only.

Screen freezes when opening UnityView two times #75

@Arnaod

Description

@Arnaod

Hi everyone,

I'm getting an head scratching bug for a few days.

My react-native app uses the unityView at several places. I can open it at every place without issues, but when I'm trying to open it two times in a row (either at the same place or different places), the screen freezes.

The screen displays the last frame that unity rendered before closing Unity.

The strangest thing is that the unityView is still running : I can ear the sounds and even click on buttons (if I remember where they are 😄)

The issue looks similar to open issues in the former module like this one for instance .

The former fix seemed to be this, but doesn't work here.

<UnityView style={{ position: 'absolute', left: 0, right: 0, top: 1, bottom: 1 }} />

Relevant code for the modal on RN side :

`class UnityModalComponent extends Component {
constructor(props) {
super(props);
const { route } = props;
this.state = {
renderUnity: true,
currentScene: route.params?.data?.scene,
};
this.shouldWait = false;
}

componentDidMount() {
const { currentScene } = this.state;
StatusBar.setHidden(true);
UnityModule.isReady().then(ready => {
if (ready) {
this.shouldWait = false;
UnityModule.postMessageToUnityManager(currentScene);
} else {
this.shouldWait = true;
}
});
}

componentDidUpdate(prevProps, prevState) {
const { renderUnity } = this.state;
if (renderUnity !== prevState.renderUnity && !renderUnity) {
const { navigation } = this.props;
navigation.pop();
}
}

componentWillUnmount() {
StatusBar.setHidden(false);
}

Did anyone encounter the issue or has any idea on how to fix this?

Thank you,

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions