Disconnected with error

Hi

In Untiy editor when I switch windows and the app loses focus and regains it, i get this exception always, and i can't reconnect:


NullReferenceException: Object reference not set to an instance of an object

Photon.Voice.Unity.Recorder.CreateLocalVoiceAudioAndSource () (at Assets/Photon/PhotonVoice/Code/Recorder.cs:1732)

Photon.Voice.Unity.Recorder.Setup () (at Assets/Photon/PhotonVoice/Code/Recorder.cs:1446)

Photon.Voice.Unity.Recorder.HandleApplicationPause (System.Boolean paused) (at Assets/Photon/PhotonVoice/Code/Recorder.cs:2129)

Photon.Voice.Unity.Recorder.OnApplicationFocus (System.Boolean focused) (at Assets/Photon/PhotonVoice/Code/Recorder.cs:2093)

UnityEditorInternal.InternalEditorUtility:OnGameViewFocus(Boolean)

UnityEditor.HostView:OnFocus()

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭

    Hi @creat326,

    Please update to the latest Photon Voice 2 and retry.

  • creat326
    creat326 ✭✭
    edited November 2021

    I have the latest Photon Voice 2 and I'm getting that error. That was the first thing I did before posting: making sure I had the latest.

  • JohnTube
    JohnTube ✭✭✭✭✭

    Hi @creat326,

    Line 1732 in Recorder.cs is not inside CreateLocalVoiceAudioAndSource method in latest Photon Voice 2.

    Please share with us what you have in that line in your code.

    Maybe you have this Unity issue where assets are not updated as expected, read more here. You can check Photon Voice 2 version from VoiceConnection or PhotonVoiceNetwork inspector on the top. Or from changes-voice.txt top entry.

  • creat326
    creat326 ✭✭
    edited November 2021

    well, it doesn't match that line because I added debug.log to try to solve it myself

    But all you need to do is add photon voice, hit play on editor, then move away from editor or just click properties of a transform or whatever, and then return to the game.

    The line in particular with the error is this one:

    return this.client.CreateLocalVoiceAudioFromSource(voiceInfo, this.inputSource, audioSampleType);

    But it's odd because I added a debug.log on top to check what was null and I saw nothing null. So it has to be inside the call or who knows.

    This is the debuglog I added right before to see if something was null, but the result doesn't seem like

    Debug.LogError("client:" + audioSampleType + ": " + this.inputSource+ " :"+ voiceInfo);

    it prints

    client:Source: Photon.Voice.Unity.MicWrapper :c=AudioOpus f=48000 ch=1 d=20000 s=960 b=30000 w=0 h=0 fps=0 kfi=0 ud=

  • Ok, i´ve just updated to the newer version today. Zero modifications. Zero debug.logs or anything added to it.

    Every

    Single

    Time

    I hit play and the click on any window and then back to playing, I get the same error. Here is. And I've tried in 3 computers. I just don't understand why you can't acknowledge it.

    NullReferenceException: Object reference not set to an instance of an object

    Photon.Voice.Unity.Recorder.CreateLocalVoiceAudioAndSource () (at Assets/Photon/PhotonVoice/Code/Recorder.cs:1728)

    Photon.Voice.Unity.Recorder.Setup () (at Assets/Photon/PhotonVoice/Code/Recorder.cs:1444)

    Photon.Voice.Unity.Recorder.HandleApplicationPause (System.Boolean paused) (at Assets/Photon/PhotonVoice/Code/Recorder.cs:2125)

    Photon.Voice.Unity.Recorder.OnApplicationFocus (System.Boolean focused) (at Assets/Photon/PhotonVoice/Code/Recorder.cs:2089)

    UnityEditorInternal.InternalEditorUtility:OnGameViewFocus(Boolean)

    UnityEditor.HostView:OnFocus()

  • JohnTube
    JohnTube ✭✭✭✭✭

    Hi @creat326,

    Hmm I see.

    First, please disable Recorder.StopRecordingWhenPaused and see if it helps.

    Then enable it again and replace Recorder.HandleApplicationPause method with this one and retry?

  • JohnTube
    JohnTube ✭✭✭✭✭

    Hi @creat326,

    Please update to Photon Voice 2.28.2 and retry.

    It contains this fix:

      FIXED: NullReferenceException when Recorder.StopRecordingWhenPaused is enabled as Recorder.HandleApplicationPause was trying to start recording without checking if it should.

    Thanks again for your report and patience.

    Your help and contribution are appreciated!

  • Fixed, thanks

  • JohnTube
    JohnTube ✭✭✭✭✭

    Hi @creat326,

    Thank you for testing and confirming.