Photonview.Owner null in OnPhotonInstantiate

I've got an interesting issue with the latest version of Photon 2 (updated today from the unity asset store, the trial version since i have a subscription online). Version is 2.19.1, lib 4.1.4.4. This is new as of this update, the version I had at the end of May did not have this issue.

I can load into a game the first time no problem, but when I leave an online room, disconnect photon, go back to the main menu, then create a second room, my main player class reports that the PhotonView.Owner field is null during the OnPhotonInstantiate function (interface implemented). This shouldn't happen, right? Is there some new process I need to follow?

Comments

  • emotitron
    emotitron ✭✭✭
    We'll probably need a basic minimal repo of this. I tried to recreate what you are describing with our test scene, and there weren't any issues with disconnecting and starting the startup process over again.

    Can you reduce this down to a small project that exhibits the problem that we can look at? @superdupergc
  • Well! I can try, but that will take me some time.

    Another thing - do we need to delete the whole photon repo and reinstall for minor revisions, the same way as recommended when going from PUN 1 to 2?

    The funny thing is in the full log, I can see the viewID being assigned 1001 as the owner when I turn on the full photon logs, it just seems to be the Photon Player object that is null. And it's definitely already joined the room by this point.
  • emotitron
    emotitron ✭✭✭
    I always delete the folder myself when changing versions, but I am not sure if that is a requirement.

    Has the OnJoinedRoom() callback fired then? Where in your code are you making this call from where the Player is null?
  • emotitron
    emotitron ✭✭✭
    I think I am getting your issue now. IPunInstantiateMagicCallback fires ahead of Awake() and is a bit of an oddball because of that. The object hasn't been set up yet, it just being instantiated.

    I will look into why owner is coming up wrong the second room join. I suspect it has to do with the new IsMine caching not fully resetting on disconnect.

  • emotitron
    emotitron ✭✭✭
    I believe I found it, you can try this to see...

    in PhotonNetwork.cs line 2504 approx
    replace
    photonViews[i].didAwake = true;
    

    with
    photonViews[i].SetOwnerInternal(parameters.creator, parameters.creator.ActorNumber);
    photonViews[i].didAwake = true;
    
  • Yes, the onjoinedroom callback has already fired; i spawn this object as a result of that callback. I'll try that, thank you!
  • emotitron
    emotitron ✭✭✭

    This change should now be live in the Asset Store.

  • Sad to say the new version still doesn't fix the issue. I'll see if I can get you a repro project soon.
  • emotitron
    emotitron ✭✭✭
    The new version on the store doesn't have the latest fix to this yet. But the fix has been changed now to:
    view.ownershipCacheIsValid = PhotonView.OwnershipCacheState.Invalid;
    photonViews[i].didAwake = true;
    

    This may be unrelated to your issue though, so we may need to wait for your repo.
  • superdupergc
    edited July 2020
    That was it, thank you! I've verified it's working for me. Thanks very much!

    (for anyone else reading - the "view" in the first line of the fix must be
    photonViews[i]
    
    )