The Photon Forum
is Closed Permanently.

After many dedicated years of service, we have made the decision to retire our Forum and switch to read-only: we´ve saved the best to last! Your search result can be found below. Plus, we offer support via these channels:

Try Our

Please check if you can find an answer in our extensive documentation on PUN.

Join Us
on Discord

Meet and talk to our staff and the entire Photon-Community via Discord.

Stack Overflow

Find more information on Stack Overflow (for Circle members only).

Write Us
an E-Mail

Feel free to send your question directly to our developers.

Photonview.Owner null in OnPhotonInstantiate

2020-06-29 20:28:57

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 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?


2020-06-30 11:57:45

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

2020-06-30 15:20:06

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.

2020-07-01 11:35:53

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?

2020-07-01 12:15:43

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.

2020-07-01 12:25:04

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

in PhotonNetwork.cs line 2504 approx


2020-07-01 15:00:34

Yes, the onjoinedroom callback has already fired; i spawn this object as a result of that callback. I'll try that, thank you!

2020-07-02 10:02:12

This change should now be live in the Asset Store.

2020-07-05 21:00:14

Sad to say the new version still doesn't fix the issue. I'll see if I can get you a repro project soon.

2020-07-06 10:49:43

The new version on the store doesn't have the latest fix to this yet. But the fix has been changed now to:

This may be unrelated to your issue though, so we may need to wait for your repo.

2020-07-06 15:37:29

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] )

Back to top