EGDictionary.m crashes on iPAD

HI,

I using the iOS SDK, and I have the same crash on the iPAD. This crash happens when I disconnect, and I try to reconnect.
iPad is running OS 9.3.5

Here is the error message
frame #0: 0x23597a66 libobjc.A.dylib`objc_msgSend + 6
* frame #1: 0x00b17c6e `-[EGMutableDictionary checkObjectTypes:forKey:](self=0x1c1188d0, _cmd=, anObject=0x17e45a80, aKey=0x1c1184f0) at EGDictionary.m:865:5 [opt]
frame #2: 0x00b1743a `-[EGMutableDictionary setObject:forKey:](self=0x1c1188d0, _cmd=, anObject=0x17e45a80, aKey=0x1c1184f0) at EGDictionary.m:802:2 [opt]
frame #3: 0x00b51b3e `::-[EGLoadBalancingPeer opAuthenticate::::::](self=0x17d57440, _cmd=, appID=, appVersion="1.0", encrypted=, authenticationValues=, lobbyStats=, regionCode=) at EGLoadBalancingPeer.mm:252:3 [opt]
frame #4: 0x00b4bdda `::-[EGLoadBalancingClient onOperationResponse:](self=0x17ee7b00, _cmd=, operationResponse=) at EGLoadBalancingClient.mm:0:6 [opt]
frame #5: 0x00b41eae `ExitGames::Photon::Internal::PeerBase::deserializeOperationResponse(this=0x18a7cc14, inBuff=, isEncrypted=, inBuffBodyLength=, msgType=) at PeerBase.cpp:604:31 [opt]
frame #6: 0x00b41ba8 `ExitGames::Photon::Internal::PeerBase::deserializeOperation(this=0x18a7cc14, inBuff="\363\203N\323$ߣ=7\nu\356$\241r\325\332tϛ\x97\365\227E\253`-\344x\361\376\xa2\x86={\x8fn\x12\334\370>\x15\344!\345j\x1cL\x06", inBuffLength=50) at PeerBase.cpp:530:38 [opt]
frame #7: 0x00b3ca90 `ExitGames::Photon::Internal::EnetPeer::dispatchIncomingCommands(this=0x18a7cc14) at EnetPeer.cpp:506:15 [opt]
frame #8: 0x00b409da `ExitGames::Photon::Internal::PeerBase::service(this=0x18a7cc14, dispatch=) at PeerBase.cpp:206:12 [opt]
frame #9: 0x00b32f34 `ExitGames::Photon::PhotonPeer::service(this=, dispatchIncomingCommands=) at PhotonPeer.cpp:169:17 [opt]
frame #10: 0x0016a4f0 `::-[PhotonEngine run](self=0x17ee7700, _cmd="run") at PhotonEngine.mm:301:9

Comments

  • Hi @Vasilis.

    As I have already mentioned in the other thread, please provide reproduction code. The two issues might be related and both should definitely not happen and never got reported before. Can you reproduce them with one of our demo projects?
  • Hi @Kaiserludi,

    I did not try to reproduce it with your demo code. Also, I do not have error on iPhone, but only on the iPad. Could it because I am running an old OS on the iPad? Does the report trace help you to identity the error?
  • Hi @Vasilis.

    i have never seen this crash before, so I assume it must be somehow related to your code. That's why I asked for a repro case.

    The code at EGDictionary.m:865 looks fine and I can't see how it could crash.
  • Hi @Kaiserludi,

    Then maybe there is something inherent to OS 9.3.5. Because, I do not have this crash on devices that run the latest version of the OS. Also, I can reproduce this crash only when I call the method to disconnect, and after a few seconds I call the method to connect.
    The good thing is that I have not heard any complains from my users!
  • Hi @Kaiserludi,

    I have this problem on devices running OS 10.3.1
    Then, I found that I have this crash only when I use the release version of the libraries Photon, Common and LoadBalancing.
    Is it safe to publish my app with the debug version of those libraries?
  • Hi @Vasilis.

    You could publish with the debug version of the libs, but in that case your app itself and all other libs that it uses should also be debug versions (as otherwise you will probably run into issues with mixing debug and release version of the runtime). This is not ideal for performance.

    However if I were you I would really just approach this properly and track down the cause of it. first I woudl figure out if it only happens with your project or if you can manage to reproduce it with one of our demo projects. In the latter case just tell us how we can reproduce it with one of the demo projects and we will look into it and provide a fix. If it is the former, then you should track down which difference between your project and the demos is causing this and fix the issue in your code.
  • Hi @Kaiserludi,

    Thank you for your quick response.

    It crashed again, even with the debug version of the libraries. But, now, I have an error that I think will help you to track it:

    FATAL: EGDictionary.m -[EGMutableDictionary checkObjectTypes:forKey:] line: 875 - An EGDictionary can't hold elements of different types at the same time. Assertion failed: (0), function -[EGMutableDictionary checkObjectTypes:forKey:], file /Development/egp/v4.1.14.x/Common-objc/src/EGDictionary.m, line 875.
  • Hi @Kaiserludi,

    I was confused by the fact that it was crashing only on devices that run iOS lower than 11.

    I think that Photon is crashing when I call opRaiseEvent and the parameter is nil.

    It does not crash all the times, but I will make sure that that parameter is not nil.

  • Kaiserludi
    Kaiserludi admin
    edited November 2019
    Hi @Vasilis.

    You need to make sure that you don't attempt to add keys or values of different types to an EGMutableDictionary than the ones that that EGMutableDictionary already holds. If you fail to do that, then the class will assert just like in the error message that you have shown.

    So the fix is to find the place in your code where you try to add a key-value pair to an EGMutableDictionary that does not match the types of any previously added key-value pair or the type that you have specified when initializing the container.

    Background info:
    EGDictionary, EGArray and their mutable subclasses are strong-typed variants of NSDictionary, NSArray and their subclasses. They internally just store their content in a NSDictionary/NSArray, but they actively prevent the user from mixing keys, values or elements with different types.
    Hence once you have added for example a key of type int with a value of type NSString to an EGDictionary, all further keys that you add to that EGDictionary also need to be of int and all further values also need to be of type NSString.

    An EGDictionary is the objective equivalent to an ExitGames::Common::Dictionary in the C++ Client and to a Dictionary in C# on the server, while an NSDictionary is the equivalent to an ExitGames::Common::Hashtable and to a Hastable in C# on the server. An EGArray is equivalent to a C-array, to an ExitGames::Common::JVector and to a strongly-typed array in C# on the Server, while an NSArray is equivalent to a c-array of type Object, to an ExitGames::Common::JVector< Object> and to an Object[] on the server.

    As Cocoa only has weak-typed containers (containers in which you can store objects of different classes), we had to add our own strong-typed containers (containers in which all stored objects are of the same class) EGDictionary and EGArray to have matching equivalents in objective C to the containers that we support in C# and C++. Otherwise there would be no way for objective C code to tell Photon if an NSDictionary should be treated like a Hashtable or like a Dictionary.

    The big advantage of a Dictionary over a Hashtable and a typed array over an Object-array (and hence of EGDictionary over NSDictionary and EGArray over NSArray) is that because all keys/values/elements are guaranteed to be of the same type, Photon only has to include the type-information once for the whole container and not once for each element. This saves bandwidth.

  • Hi @Kaiserludi,

    I am updating the room properties and the player properties. Both of these are NSDictionary. I strongly believe that the issue was that I was passing nil, even though, it is hard to reproduce it.