viromedia / viro

ViroReact: AR and VR using React Native
MIT License
2.31k stars 483 forks source link

Animation stopped after navigate.goBack() #518

Open tansangxtt opened 5 years ago

tansangxtt commented 5 years ago

Environment

Please provide the following information about your environment:

  1. Development OS: Windows 10 Build 1809
  2. Device OS & Version: Android OS version 8.0
  3. Version: ViroReact v2.13.0 and React Native v0.57.7
  4. Device(s): Samsung Galaxy S7 (G930FD)

Description

First of all, I just focus on Android and have tested to run it on Samsung Galaxy S7. I use React-Navigation for navigating. In my app, I have this StackNavigator:

const AppNavigator = createStackNavigator(
    {
        login: Login,
        home: Home,
        earnCoins: EarnCoins,
        profile: Profile,
    },
    {
        initialRouteName: "login",
        headerMode: 'none'
    });

At Home scene and Profile scene, I add Viro3DSceneNavigator for showing a multipart animated 3D models. According to Viro document, I need to set initialScene.

For Home scene,

<Viro3DSceneNavigator style={styles.viro} apiKey="2AE4B758-D40B-4EE5-858A-54C8CE1CED20" viroAppProps={this.state.viroProps} initialScene={{ scene: AvatarHome3DScene }} />

For Profile scene,

<Viro3DSceneNavigator style={styles.viro} apiKey="2AE4B758-D40B-4EE5-858A-54C8CE1CED20" viroAppProps={props} initialScene={{ scene: Avatar3DScene }} />

My app flow is:

- Login scene -> click button "Next"
                                        -> Home scene -> Click "Profile" -> Profile scene
                                                    \--> Click "EarnCoins" -> EarnCoins scene

And "Back" button is implemented: navigate.goBack()

My issue: Animation is stopped when nagivate.goBack()

I checked a lot of documents and issues related to Viro3DSceneNavigator but I haven't found any solution. Also, I added "Feed" button in the Home Scene to call setState in order to re-render Viro3DObjects but nothing changed

Reproducible Demo

At Home scene, the animation work well. If I navigate to Profile and go back from there, the animation (Home scene) will be stopped. However, If I go back to the "Login" scene and click "Next" to "Home" scene, the animation (at Home scene) work normally again

achuvm commented 5 years ago

Hi @tansangxtt,

Sorry for the delayed response, it looks like you're running multiple Viro3DSceneNavigators at the same time. This isn't really a supported use case and may lead to undefined behaviors like what you observe. To mitigate the issue, you can consider using a static image in the side view rather than a 2nd Viro3DSceneNavigator.

Thanks,

tansangxtt commented 5 years ago

Hi @tansangxtt,

Sorry for the delayed response, it looks like you're running multiple Viro3DSceneNavigators at the same time. This isn't really a supported use case and may lead to undefined behaviors like what you observe. To mitigate the issue, you can consider using a static image in the side view rather than a 2nd Viro3DSceneNavigator.

Thanks,

Thanks @achuvm for your reply

First, if I use only 1 Viro3DSceneNavigator, I have to do the navigation manually and not sure it works properly. Basically, I want to put the animated 3D model in 3 separated scenes. As I understand your ideal, I need to show/unshow the 3D model? One more related issue, there is an AR scene and ViroARSceneNavigator is used as well. After goback() from here, the animation also is stopped Do you have any advise, recommendation for this situation? Thank you

tansangxtt commented 5 years ago

Hi @achuvm, after many tries, I found that Viro3DSceneNavigator cannot be used more than one time although I used it in the different components. Because it is necessary and natural to show the 3D model in different scenes (react-native UI)

Could it be a bug or limitation?