Getting multiple PhotonView Update Errors after updating to latest Package

Options

Hello,

Recently I upgraded my Unity project from 2019.7.1f1 to 2021.2.9f1. Because of this I also had to upgrade the photon package I was using, which is PUN 2. Recently I've been having problems with loading into scenes. I use my own scene loading solution since I use addressables and additive scenes. And I never had a problem with these errors:

"Failed to find a PhotonView with ID=55 for incoming OwnershipUpdate event (newOwnerActorNumber=1), sender=1. If you load scenes, make sure to pause the message queue."

The kicker is this though. When Master Client loads the room > then the scenes, everything is fine and networked. Anyone else that tries to load into the room gets these errors. Loading the same scenes and everything, a bunch of those errors. Weird thing is if we move into the next set of scenes, no errors. So I've deduced it's the initial loading in. I've tried everything from pausing the message queue to setting automatically syncing scene. Here's the snippet of code that does all the loading:

using System;
using System.Linq;
using UnityEngine;
using Photon.Pun;
using Photon.Realtime;
using Tevolve.SceneManagement;
using UnityEngine.Serialization;

public class Launcher : MonoBehaviourPunCallbacks {
    
    public static string gameVersion = "0.9";
    
    [SerializeField]
    private string multiplayerBaseScene = "MultiplayerComponent";
    
    [SerializeField]
    private MenuController menu = default;
    
    [SerializeField]
    private GameSettings[] gameSettings = default;
    
    public GameSettings[] GameSettingsList => gameSettings;
    
    private void Start() {
        PhotonNetwork.AutomaticallySyncScene = true;
    }

    public void Connect() {
        if(!PhotonNetwork.IsConnected) {
            menu.ShowLoading();
            PhotonNetwork.PhotonServerSettings.AppSettings.AppVersion = gameVersion;
            PhotonNetwork.GameVersion = gameVersion;
            PhotonNetwork.IsMessageQueueRunning = false;
            PhotonNetwork.ConnectUsingSettings();
        }
    }

    public void Disconnect() {
        menu.ShowLoading();
        PhotonNetwork.Disconnect();
    }

    public void Refresh() {
        PhotonNetwork.JoinLobby(TypedLobby.Default);
    }

    public override void OnJoinedLobby() {
        if(menu != null)
            menu.ShowRooms();
    }

    public override void OnConnectedToMaster() {
        PhotonNetwork.JoinLobby(TypedLobby.Default);
    }

    public override void OnDisconnected(DisconnectCause cause) {
        if(cause == DisconnectCause.DisconnectByClientLogic) {
            menu.ShowName();
        } else {
            Connect();
        }
    }

    public override void OnCreatedRoom() {
        //Add custom properties to the current room
        var newProperties = PhotonNetwork.CurrentRoom.CustomProperties;
        newProperties["game"] = GameManager.CurrentGameName;
        PhotonNetwork.CurrentRoom.SetCustomProperties(newProperties);
    }

    public override void OnJoinedRoom() {
        PhotonNetwork.IsMessageQueueRunning = false;
        //print("Loading base scene");

        //Obsolete
        //GameSceneManager.LoadBaseScene((string)PhotonNetwork.CurrentRoom.CustomProperties["game_base"], GameSceneManager.MuliplayerModes.PLAYER);

        var gameName = (string) PhotonNetwork.CurrentRoom.CustomProperties["game"];

        Debug.Log($"Photon: Joining game \"{gameName}\"");
        Debug.Log($"Photon: Available games: {gameSettings.Select(settings => settings.gameName).ToArray().ToStringFull()}");

        var game = gameSettings.First(settings => settings.gameName == gameName);

        SceneUtility.LoadScenesAdditive(new[] {multiplayerBaseScene}, () => {
            SceneUtility.LoadScenesAdditive(new[] {game.baseScene}, () => {
                // Enable multiplayer component
                var gameLoader = FindObjectOfType<GameLoader>();

                gameLoader.ActivateGame();
                gameLoader.StartCoroutine(gameLoader.EnableMessageQueue());
            });
        });
    }

    public override void OnCreateRoomFailed(short returnCode, string message) {
        PhotonNetwork.JoinLobby(TypedLobby.Default);
        print("#Photon# Failed to create room, code: " + returnCode + ", err: " + message);
    }

    public override void OnJoinRoomFailed(short returnCode, string message) {
        PhotonNetwork.JoinLobby(TypedLobby.Default);
        print("#Photon# Failed to join room, code: " + returnCode + ", err: " + message);
    }
}


Answers

  • Tobias
    Options

    Please check if OnJoinedRoom gets called early enough to properly pause the message queue. Likely it gets called later than the built-in scene syncing and you already get/dispatched the event for the ownership update.

    So .. please check if the warning log happens before or after you paused the queue (for loading).

    Is the PhotonView (in this case 55) loaded with the scene? Can it be destroyed by anyone?