Extreme lag spikes on Mac + Photon microphone + React on system changes enabled

As per the title, when running on a Mac using the Photon microphone type and "React on system changes" enabled, the program halts to 1 FPS.
This doesn't happen with Unity microphone type, or on Windows, or with "React on system changes" disabled. I could only recreate it with all 3 of these conditions simultaneously.

The offender seems to be AudioSettings.InvokeOnAudioConfigurationChange which is called very frequently (even with no device change) and takes up 90% of frame time.

Comments

  • Hi @EranJ,

    Thank you for your report.
    For the time being you could disable ReactOnSystemChanges until we fix this on macOS.
  • Hi @EranJ,

    Could you replace "Recorder.OnAudioConfigChanged" with the following and try again:
    private void OnAudioConfigChanged(bool deviceWasChanged)
            {
                if (this.Logger.IsInfoEnabled)
                {
                    this.Logger.LogInfo("OnAudioConfigChanged deviceWasChanged={0}", deviceWasChanged);
                }
                if (deviceWasChanged && this.IsRecording)
                {
                    if (this.SourceType == InputSourceType.Microphone)
                    {
                        PhotonMicrophoneEnumerator.Refresh();
                        if (this.MicrophoneType == MicType.Photon)
                        {
                            this.RequiresRestart = !PhotonMicrophoneEnumerator.IDIsValid(this.photonMicrophoneDeviceId);
                        }
                        else
                        {
                            this.RequiresRestart = !IsValidUnityMic(this.unityMicrophoneDevice);
                        }
                        if (this.RequiresRestart)
                        {
                            this.RestartRecording();
                        }
                    }
                }
            }
    
  • @JohnTube Can confirm this removes the lag, though the audio would not send from mac.

    Othewise It is working fine with mic set to Unity on unity version 2019.3.5
  • Hi @Psyco,

    Thank you for choosing Photon!

    Do you have Recorder.ReactOnSystemChanged enabled (true)?
    What about Recorder.SkipDeviceChangeChecks?
  • PsycoPsyco
    edited May 2020
    Will be able to test later in the week, currently everything is working very nicely with the Unity mic option and I'd rather not break it :smile:
Sign In or Register to comment.