iOS Client crashes 100% when another user joins Interest Group

Hello all,

Let me start quickly by saying networking and debugging ios are far from my strong suits, so apologies if I'm missing something obvious.

I have a small project I started to test and configure PUN before implementing it into my main mobile game project. The project I'm testing this on is a basic 2019.3.1f1 URP, with nothing more than PUN in it. I have a basic menu setup for the user to connect to Photon Master Server, set a nickname and interest group, and then join a room. When they join the room, they're just placed into the Unity Demo scene with the half-built construction scene. There is basic movement control for PC, and no movement controls for mobile. That's all there is, as bare-bones as I could make it.

The problem is: when a mobile device has more than itself in its interest group (either by joining someone else, or having someone join it), it will crash. Xcode does little to help, mostly just pointing at Ln26 of MainApp/main.mm in the Xcode project file:

Error Message
Thread1: EXE_BAD_ACCESS (code=1, address=0x0)

MainApp/main.mm
#include <UnityFramework/UnityFramework.h>

UnityFramework* UnityFrameworkLoad()
{
    NSString* bundlePath = nil;
    bundlePath = [[NSBundle mainBundle] bundlePath];
    bundlePath = [bundlePath stringByAppendingString: @"/Frameworks/UnityFramework.framework"];

    NSBundle* bundle = [NSBundle bundleWithPath: bundlePath];
    if ([bundle isLoaded] == false) [bundle load];

    UnityFramework* ufw = [bundle.principalClass getInstance];
    if (![ufw appController])
    {
        // unity is not initialized
        [ufw setExecuteHeader: &_mh_execute_header];
    }
    return ufw;
}

int main(int argc, char* argv[])
{
    @autoreleasepool
    {
        id ufw = UnityFrameworkLoad();
        [ufw runUIApplicationMainWithArgc: argc argv: argv];      <---- DEBUGGER POINTS HERE
        return 0;
    }
}

The debug console in Xcode is just repeating this until the crash, and nothing afterwards:
TCP < 70 OK
ExitGames.Client.Photon.MyAction:Invoke()
ExitGames.Client.Photon.TPeer:DispatchIncomingCommands()
ExitGames.Client.Photon.PhotonPeer:DispatchIncomingCommands()
Photon.Pun.PhotonHandler:Dispatch()
 
(Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)

(lldb)
  • Built for PC, the issue is non-existent. I can add as many users to any interest group, everything functions as expected.
  • If the iOS build is left running without other users, it will run without crashing (tested for long periods of time).
  • A PC build logging in as a master unit/interest group, which can see all other users, and not be seen by any, does not cause the iOS build to crash, and can successfully see it.

I've read that iOS will log out if the app goes into background, but that never happens. I've read that Apple requires TCP, so I've only used that.

I'm just fully stumped. Can anyone help me out?

Thanks,
Michael

BUILD INFO:
Unity 2019.3.1f1
PUN 2.18.1 (FREE)
iOS 13.4.1
iPhone XR & iPad Pro

Comments

  • (I don't see a way to edit the post, so I'll just add a quick little clarifying bit here)


    • For the crash, it does not matter what platform/device the other user is in the interest group, the iOS build will crash if anyone joins or is already in its interest group.
    • If they are both iOS, they will both crash.
    • If one is PC and the other iOS, only iOS crashes, and the PC will continue on as if the player just dropped.
    • The crash can take upwards of a minute to happen after there are two user in the interest group.
  • JohnTube
    JohnTube ✭✭✭✭✭
    Hi @KkachiGames,

    Thank you for choosing Photon!

    It looks like you're maybe sending too much data to that interest group, more than an iPhone can handle.
    Did you consider this?

    Or maybe this is a result of receiving events sent to that interest group.
    Maybe there is an exception or error happening due to that on iOS build.
  • Hi John, thanks for the response.

    Too much data certainly sounds like something that would be an issue with the mobile device, but I'm not sure if it is now. The only data being passed around is a simple prefab for each user, containing a simple low poly mesh, a text object, and a simple script for controls (PC). The prefab has a Photon Transform View sending position and rotation, with Observe option set to Unreliable.

    They're instantiated by the following method:
    [PunRPC]
        private void SpawnPlayer()
        {
            var thisObject = PhotonNetwork.Instantiate(playerPrefab.name, new Vector3(0, 1.5f, 0), Quaternion.identity, (byte)myGroup);
    
            //-- Names it for Unity's sake. Not required for Photon
            thisObject.name = PhotonNetwork.LocalPlayer.NickName; 
    
            //-- To grab the InterestGroup
            var pView = thisObject.GetPhotonView();
            myGUI.text += pView.Group;
    
            ccp = thisObject.GetComponent<CharacterControlPhoton>();
    
        }
    

    Running the app as iOS in the Unity Editor does not cause the crash, which to me makes me also think it's a data issue, but it seems like its so little, I'm just not sure.

    Perhaps this adds information to the matter: After the player joins the master server, there is a lobby screen showing available rooms. This list is updated live on the PC build, but never shows a room on an iOS device. When run as iOS in the editor, the list is updated as expected. Another received data issue?

    If this is the issue, what would be the best way to handle it? If I remove the photon view from the prefab, there would be no use for Photon at all. Showing the other players location is all I'm doing and all I need for my app.

    Thanks again for your help!
  • JohnTube
    JohnTube ✭✭✭✭✭
    Hi @KkachiGames,
    Perhaps this adds information to the matter: After the player joins the master server, there is a lobby screen showing available rooms. This list is updated live on the PC build, but never shows a room on an iOS device. When run as iOS in the editor, the list is updated as expected. Another received data issue?
    I would solve this first. It looks like the iOS build client cannot see the other clients. Go over the "Matchmaking Checklist" carefully, especially the point about regions.
  • Hey @JohnTube, thanks again for the response.

    I've been working on this on and off for a couple weeks now, but haven't made any progress. I went over the Matchmaking list, but don't see any issues with my build concerning those points. I have the Fixed Region set to eu, and have any option concerning versions set to the same number.

    The PC or editor will always see other games in the lobby list, even if the game was created on iOS. iOS will still never see anything in the lobby, regardless of where it was made. I use the command PhotonNetwork.ConnectUsingSettings().

    After reading through the checklist, I tried getting more manual with it (which would actually be my preference for the actual app I want to implement this into), using PhotonNetwork.ConnectToRegion("eu"), but I always receive errors with this. I tried setting PhotonServerSettings in the lines preceding the ConnectToRegion, and I tried removing those lines, but it always gives this error:
    OperationResponse 230: ReturnCode: 32767 (Invalid application id). Parameters: {} Server: NameServer Address: ns.exitgames.com:4533
    

    ( Which is a whole other enigma! haha. I double checked my ApplicationID. I have it set correctly in the PhotonServerSettings in the inspector, and I set it correctly in the script. I even trashed my test app in Photon's backend, and created a new one, with a new appId, but that didn't change the issue.
    BUT that error only comes from ConnectToRegion. If ConnectUsingSettings, that error is not a problem...)


    SO, my current situation is the same, and I'm not sure what to even check next, or experiment with, or search for...
    • * The test app has very little in it. It spawns a prefab for each player with a basic geometric mesh, and a text label for their name. They can move with basic controls. This prefab is the only thing with a PhotonTransformView, and thus, the only data being sent (I believe?).
    • * Everything works as expected on PC and in the Editor, regardless of what the editor is set to build for.
    • * iOS builds can not see any games listed in the lobby, but can connect if they type in the game's name and JoinOrCreate.
    • * iOS builds on phones and tablets will crash within a second or two of receiving data.
    • * iOS builds can send data with no issues. If other builds are set to Master interest group, the iOS build will properly send it's data to the Master, and not crash.
    • * iOS builds that login to Master interest group will crash when any other build logins in (because they receive the data).

    So, clearly iOS is crashing when it receives any data. Photon is made for iOS and Android, right? (not being rude, I'm really asking) I don't understand what I'm doing wrong here.

    Sorry for the long post. I don't mind bugs and problems etc, but this one is really annoying me. I guess because I don't even know where to continue with it. Thank you anyone for your help, I really appreciate it!

    Michael
  • JohnTube
    JohnTube ✭✭✭✭✭
    Hi @KkachiGames,

    When you use PhotonNetwork.Connect method other than ConnectUsingSettings you need to set all PhotonNetwork.NetworkingClient values manually like AppId, etc. before. In ConnectUsingSettings those values are gathered automatically from ServerSettings ScriptableObject. So why do you need to call a connect method other than ConnectUsingSettings? if you want a fixed region just set it in the ServerSettings. You could also change the settings on the fly via code PhotonNetwork.PhotonServerSettings.AppSettings.

    About iOS crash itself, try to reproduce using any of our demos in the package.
    Otherwise, send us minimal repro steps or minimal repro project.
  • KkachiGames
    edited July 2020
    Hi @JohnTube,

    I started playing with ConnectToRegion because I was trying to force a specific region, based on your earlier response, to make sure all builds and devices were on the same region/server.

    As for my actual app, I'd like to be able to set it manually because my app is event based, meaning users will only login at specific times and places, so I just wanted to make sure no one accidentally became connected to a different region than anyone else. I imagine the likelihood of that is slim, though.

    As I mentioned earlier, I do set the settings. Specifically, the method looks like this:
    public void ConnectToPhoton()
        {
            //-- Best Region Connect
            PhotonNetwork.NickName = nameInput.text;
            PhotonNetwork.GameVersion = "0.1";
            Debug.Log($"Connecting to Photon server...\nConnting with version: {PhotonNetwork.GameVersion}\nConnecting as: {PhotonNetwork.LocalPlayer.NickName}");
            
            // PhotonNetwork.ConnectUsingSettings();
    
            //-- Manual Region Connect
            PhotonNetwork.PhotonServerSettings.AppSettings.AppIdRealtime = "XXXXXXXXXXXXXXXX"; 
            PhotonNetwork.PhotonServerSettings.AppSettings.AppVersion = "0.1";
            PhotonNetwork.PhotonServerSettings.AppSettings.UseNameServer = true;
            
            PhotonNetwork.ConnectToRegion("eu");
            
        }
    

    And, obviously, the bottom four lines are commented out when I use ConnectUsingSettings. (And the X's would be my AppId from Photon)

    I'll try to play around with the demo scenes and see if they work, and report back if I figure anything out.

    Thanks,
    Michael