Why photon C++ client disconnecting application when switching among scenes automatically?

AnkitKushwah
edited July 2017 in Native
Hi,
I am using cocos2dx and I am in big trouble. I tried a lot but couldn't figure out what's going on. I have three scenes, MainMenuScene, SceneOpponentSearch and SceneGame. SceneOpponentSearch is pushed as a child of MainMenuScene.
I am launching an event from SceneOpponentSearch to MainMenuScene to replace the MainMenuScene with SceneGame. But Before launching that event I am creating a room for 2 players.
But when I come back to MainMenuScene after finishing the SceneGame My application is disconnecting automatically.

What can cause disconnect the application from photon? I am not calling disconnect() explicitly.

This is the crash report :

1 ExitGames::Common::Object.getData (Object.cpp:173) libMyGame.so
2 ExitGames::Common::Object.Object (Object.cpp:65) libMyGame.so
3 ExitGames::Common::JVector.operator= (JVector.h:168) libMyGame.so
4 ExitGames::Common::Hashtable.Hashtable (Hashtable.cpp:45) libMyGame.so
5 ExitGames::LoadBalancing::Client.opCreateRoom (Client.cpp:562) libMyGame.so
6 ExitGames::LoadBalancing::Client.onArrivalAndAuthentication (Client.cpp:1543) libMyGame.so
7 ExitGames::LoadBalancing::Client.onOperationResponse (Client.cpp:879) libMyGame.so
8 ExitGames::Photon::Internal::PeerBase.deserializeOperationResponse (PeerBase.cpp:565) libMyGame.so
9 ExitGames::Photon::Internal::PeerBase.deserializeOperation (PeerBase.cpp:511) libMyGame.so
10 ExitGames::Photon::Internal::EnetPeer.dispatchIncomingCommands (EnetPeer.cpp:509) libMyGame.so
11 ExitGames::Photon::Internal::PeerBase.service (PeerBase.cpp:194) libMyGame.so
12 ExitGames::Photon::PhotonPeer.service (PhotonPeer.cpp:174) libMyGame.so
13 ExitGames::LoadBalancing::Client.service (Client.cpp:477) libMyGame.so
14 NetworkLogic.run (NetworkLogic.cpp:289) libMyGame.so
15 NetworkManager.update (NetworkManager.cpp:19) libMyGame.so
16 MainMenuScene.update (MainMenuScene.cpp:104) libMyGame.so
17 0x3a libMyGame.so!_ZZN7cocos2d9Scheduler14scheduleUpdateINS_4NodeEEEvPT_ibENKUlfE_clEf
18 std::_Function_handler >._M_invoke (functional:2039) libMyGame.so
19 std::function.operator() (functional:2439) libMyGame.so
20 cocos2d::Scheduler.update (CCScheduler.cpp:859) libMyGame.so
21 cocos2d::Director.drawScene (CCDirector.cpp:277) libMyGame.so
22 cocos2d::Director.mainLoop (CCDirector.cpp:1443) libMyGame.so
23 Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeRender (Java_org_cocos2dx_lib_Cocos2dxRenderer.cpp:18) libMyGame.so
24 0x34c501

Comments

  • Hi @AnkitKushwah.

    Are you continuing to call service() while the main menu scene is not active?
    This sounds like a timeout disconnect is happening because you are not calling service() while SceneGame is active. Could that be the case?

    However a disconnect even when not triggered by an explicit call to disconnect() should still happen gracefully and by no way trigger a crash.

    So something else must happen here that causes the crash.

    Might it be that both scenes share a pointer to the Photon Client instance and one of them deletes it, while the other one is still calling service() on it?


    Can you reproduce this with one of our demos or does it only happen in your game?
  • AnkitKushwah
    edited July 2017
    Hi @Kaiserludi ,

    You are right. That solved the problem. I wasn't calling service() in some scenes.
    Thanks.