This document is about: VOICE 1
SWITCH TO

Photon Voice 1 is the original and first major version of Photon Voice. It is now replaced by Photon Voice 2 which is refactored and enhanced. We highly recommend starting new projects with Photon Voice 2 and if possible migrating existing ones from Photon Voice 1 to Photon Voice 2. Photon Voice will be maintained for the coming months. We will fix important bugs and support new Unity versions but new features will be added only to Photon Voice 2.

Known Issues

On this page, we will list known issues with Photon on the various platforms. The focus here is on issues which we can't fix or workaround. In some cases, this means we will simply list broken versions per platform and guide you to other versions.

Running in Background

On mobile platforms, if the app moves to background it pauses the main message loop which is responsible for keeping the client connected among other things.

Typical causes of this are:

  • Player hits "home button".
  • Phone call received.
  • Video ads.
  • Third party plugin that introduces an overlay view in the app (e.g. Facebook, Google, etc.).

On iOS, applications can not keep a connection, while in background (see Background Execution on the Apple dev pages). It might make sense to Disconnect the client, when the app switches to the background.

On WebGL, it might also make sense to set a PlayerTTL and reconnect to the session when the tab is back in focus. Often, browsers will not run JS and WebAssembly in the background. In some cases, this can be worked aorund by playing audio (even inaudible one) while in the background.

If the app is paused for longer than the client disconnect timeout (10 seconds by default) the client will be disconnected and you need to reconnect as soon as the app is "unpaused". A "timeout disconnect" callback will be triggered only after the app back from being in the background.

If the game design enables a player to return after several seconds or minutes, then you could also reconnect and rejoin the game again. If you want to rejoin the same room with same actor number when the app is unpaused you need to take few things into consideration:

  • PlayerTTL: the room needs to be created with a PlayerTTL value high enough that permits a player to return after a while.
  • EmptyRoomTTL: the room needs to be created with an EmptyRoomTTL value high enough to keep the room alive for a while when the last joined player's app is in the background.

Unity

Endless Compile Errors On Import

Some Unity Editor versions create incorrect .sln and .csproj files. It may be temporary. You can regenerate the project via a button in the Preferences "External Tools" panel.

You may want to update or reinstall the Visual Studio Editor package from the Unity Package Manager. This could also solve the project creation issues.

Sometimes assets are not updated properly from the Assset Store as old packages are stuck in the local offline cache. To fix this, first remove the Photon asset package locally, then try downloading and importing again. The paths for the local Unity assets store cache folder are listed here.

ArgumentException in Socket.SetSocketOption

There was a known Unity issue which caused IL2CPP builds to fail to connect with an "ArgumentException: Value does not fall within the expected range. at System.Net.Sockets.Socket.SetSocketOption". This happened when the Windows 10 SDK 10.0.19041.0 was installed.

Affected Unity versions: 2018.4.23f1, 2019.4.0f1, 2020.1.0b11, 2020.2.0a13. Many more minor Unity releases have been affected, too. Fixed versions are: 2020.1.1f1 and 2019.4.5f1 and up. Presumably, 2018.4.27 is also fixed. A workaround for 2018.4.23 exists as described here.

Unity 2018.2 Sockets Freeze with .Net 4.x

Unity 2018.2 used a Mono version, which could freeze communication via sockets. Depending on the message size and frequency, this happened sooner or later.

Eventually 2019.2 got a fix for this and 2018.3 should also have it at some point.

When using Mono and .Net 4.x or .Net Standard 2.0, we recommend to use the 2018.4.x or 2019.4.x releases.

RunInBackground

Unity's Application.runInBackground is not supported on mobile platforms. Instead, the OnApplicationPause method is called whenever the app moves to or back from background:

C#

void OnApplicationPause( bool pauseStatus )
{
    if (pauseStatus)
    {
        // app moved to background
    } else
    {
        // app is foreground again
    }
}

IOS App Store Submission Rejects

Sometimes, submissions for the App Store are being rejected by the Apple team, due to connection issues. We tried to sort this out with Apple and now this is rare but can still happen. Typically, UDP is being blocked in those cases. Newer Photon clients can automatically fallback to using TCP, if UDP is not connecting. You will have to appeal the rejection and in doubt, have to ask for Apple's Developer Support to take over. Their setup usually supports UDP. See this discussion in the forum for help.

iOS IPv6

While Unity 5.x should support IPv6 on iOS in general, some versions (like 5.4) break this feature. Some of the supported versions are: 4.7.2, 5.1.5, 5.2.5, 5.3.4p4, 5.4.0p1 and newer (see Unity blog post).

UWP / Windows Store Capabilities

If you target Windows Store (UWP) and you are having exceptions when you try to connect or you have this error:

A network capability is required to access the network!

Make sure to enable the required capability from Unity's "Player Settings" -> "Publisher Settings" -> "Capabilities -> "InternetClient"

required capability for windows store apps
Required Capability for Windows Store Apps. You also need the 'Microphone' capability, if you use Photon Voice.

UWP applications are isolated from others and as a feature can not connect to a server running on the same Windows instance. See Microsoft documentation for "AppContainer Isolation".

UWP Exports

If you want to export your Unity application to UWP you can either use .NET or IL2CPP as scripting backend. Photon PUN or Photon Realtime Unity SDKs are already configured to choose the correct library in order to successfully export the application from Unity. If however something goes wrong while exporting please check and make sure that you are using the correct library for the certain scripting backend:

Photon Voice

Android Microphone Permission

Requesting Android permissions were added in Unity 2018.3. You can read about it here where you can find an example of how to request Microphone permission.

Usually, when building for the Android platform, most permissions will be added automatically by Unity to the manifest file. The two permissions required by Photon Voice are:

  • android.permission.INTERNET: automatically added via Unity's Player Settings.
  • android.permission.RECORD_AUDIO: automatically added when Unity's microphone API is used.

However, with Android Marshmallow there seems to be a problem due to the newly introduced permissions model. The generated APK will be missing android.permission.RECORD_AUDIO permission and the application will not be able to record your voice. To avoid such issues update to the latest Unity version when targeting Android SDK level 23.

Unity's default behaviour asks for all permissions as soon as the application is opened. You can disable this by adding a line to the "AndroidManifest.xml" file:

XML

<application <!-- your application's attributes --> >
    <meta-data android:name="unityplayer.SkipPermissionsDialog" android:value="true" />
</application>

If you do so, you need to request the microphone permission by yourself. Otherwise, Photon Voice will not work. You could make use of this plugin.

iOS Microphone Permission

You need to add a "Microphone Usage Description" to your project's "Player Settings" under "Other Settings" -> "Configuration" section as shown in the screenshot below:

microphone usage description in player settings for ios
Microphone Usage Description in Player Settings for iOS.

Alternatively, you must add NSMicrophoneUsageDescription key to "Info.plist" in Xcode project exported by Unity. The string value should explain why your application uses a microphone. Failure to do so may result in:

  • Rejection of build submission by Apple.
  • Crashes.

macOS Microphone Permission

You need to add a "Microphone Usage Description" to your project's "Player Settings" under "Other Settings" -> "Configuration" section. This ensures that NSMicrophoneUsageDescription is added to the plist in the macOS application bundle package Contents. You could also modify that manually if you wish.

However you may also need to add the follwing entitlements:

Plain Old Text

com.apple.security.device.audio-input
com.apple.security.device.microphone

Read more here.

Failure to do so may result in:

  • Crashes.
  • Microphone silent failures: no audio input will be recorded.

Unity Microphone Issues

  • On some Unity versions, Microphone.Start() may throw a null pointer exception or return 0 channels. The latter may result in the following exception:

    ArgumentOutOfRangeException: Must be Mono or Stereo

  • On some Unity versions, the reported sample rate could be 0 from the microphone clip. For more information check out this Unity issue tracker link.

  • On some Unity versions, input device switching is broken on Windows: no matter what Unity microphone device you choose, only the default one is used for recording. For more information check out this Unity issue tracker link.

Frequency Warnings

In case you encountered a warning similar to this one:

MicWrapper does not support suggested frequency 48000 (min: 44100, max: 44100). Setting to 44100

It means that the sampling rate set can't be used due to hardware limitations.

Local voice #1 audio source frequency 44100 and encoder sampling rate 24000 do not match. Resampling will occur before encoding.

This other warning is about resampling (affecting performance in theory) which occurs when microphone frequency does not match encoder frequency. It's a good practice to set microphone frequency to the same value as the encoder's whenever possible.

Opus encoder supports a few fixed frequencies for the incoming signal. You should choose them when creating a local voice. It does not make sense to feed local voice with data of different frequency. So, when you set up the capture device, you set the same frequency for it. However, some devices do not allow arbitrary frequencies (e.g. Android). The closest available and supported frequency is set in this case.

Native Library Updates

unity editor warning for native library files
Unity Editor Warning For Native Library Files.

If a native library file is loaded using code when in play mode inside the Unity Editor it will not be unloaded unless you close the Editor. Unity Editor will throw an error (see screenshot below) when you try to import and update a native library file if the latter is already loaded in memory because you entered play mode at least once. Even if you manually delete it while the Editor is still open the issue persists whether you do it from within or outside the Editor itself. So make sure you restart the Unity Editor when updating Photon Voice and do not enter play mode before doing the update.

unity editor native library import error
Unity Editor Native Library Import Error.

Android 64-bit Support

Photon Voice provides Android 64-bit compatible libraries starting from versions 1.18 and 2.4. Minimum supported Unity versions are 2017.4 LTS and 2018.2. For the full list of Unity versions that support Android 64-bit and instructions go to this link.

iOS Speaker Issue

Unity has a known issue with iOS (mostly iPhone) where the "ear speaker" (the one on the top of the front of the device used for phone calls) is used as default audio output device instead of the loudspeaker (also called internal speaker) or any other plugged or connected headphones, headset or earpieces.

This issue is also sometimes referred to as "low volume".

Link to the Unity Issue Tracker.

To address this issue we recommend the following:

  1. If you are using Photon Voice 1 upgrade to Photon Voice 2.
  2. Use Photon as Recorder.MicrophoneType.
  3. If 1 and 2 are not possible:
    a. If you use Unity 2018.3 or newer, you can enable "Force iOS Speakers when Recording" from iOS Player Settings.
    b. Make use of "UnitySpeakerFix".
  4. Tweak iOS audio session parameters from Unity Editor or via code using Recorder.SetIosAudioSessionParameters methods. You can choose values from presets or define custom ones manually. Read about iOS audio session here. Using custom settings is advanced and should be last resort as it requires a lot of experimentation, tests, trials & errors. We recommend using presets VoIP or Game unless there is use case where those do not work or there is a tested combination that works better.

iOS Silent/Ring Switch and Muting

By design, most iOS audio session categories will not allow muting when configured. For more information check out Table B-1 here. For instance, using the default audio session category used is "PlayAndRecord" (AVAudioSessionCategoryPlayAndRecord) (set via "Game" preset), the hardware switch to "Silent" will not mute your application and also you cannot lower the volume to zero.

Oculus OVR SDK

If you use the Oculus OVR SDK, you need to disable the "Can Own Microphone". This option gives exclusive microphone control to Oculus OVR SDK and it could be preventing Photon Voice Recorder from accessing the microphone properly.

You can find it here: "LocalAvatarWithGrab" or "(+)LocalAvatar" GameObject -> "Ovr Avatar (Script)" component -> "Can Own Microphone" checkbox, un-check it.

Echo or Noise

First, always update to the latest Photon Voice 2.

Things that could cause echo:

  • testing using multiple devices that are not far enough from each other so the microphone input of one gets the output from the speaker of the other.
  • testing using debug echo: Recorder.DebugEchoMode set to true.
  • testing using multiple clients on the same machine.

Things to try to reduce echo or noise:

  • native audio input plugin: try Photon microphone type.
  • software audio processing (WebRTC based): try WebRtcAudioDsp component attached to the same GameObject as the Recorder, enable AEC / AEC Mobile and NoiseSuppression.

If the issue is resolved by the usage of headphones, we recommend adding a message to your users (e.g. after splashscreen) that the usage of headphones is recommended for a better audio experience like many apps do.

Low Volume

First you need to find out if the low volume issue is due to input or output. You can do so using an AudioClip file (that you know its loudness is OK) as input source + DebugEchoMode. If it's the output, you need to increase volume of the speakers or fix any issue related to the output audio device. If it's the input and the input source is microphone:

Depending on the platform you target you can choose to:

  1. use Photon microphone type.
  2. add WebRtcAudioDsp component next to the Recorder component (at compile time or at runtime before recorder is started) being used and enable "AGC" (Automatic Gain Control) then adjust "AGC Compression Gain" if needed.
  3. add MicAmplifier component next to the Recorder component (at compile time or at runtime before recorder is started) being used and tweak its values.

High Pitch

Although this section is named 'High Pitch' as that's the most common key words used to describe a recurring playback issue, we tried to list possible solutions for other playback issues here as well. We also shared a few tips on how to adjust playback delay settings for music streaming.

Every now and then you can notice pitch changes in Photon Voice Speaker playback for a few seconds because it's trying to catch up.

This is a consequence of code changes we made in the audio player (UnityAudioOut) to better handle network delay variations (this happened in 2.20).

So to address this, we have added (in v2.22) a couple of parameter values to adjust playback delay.

You can set advanced playback delay settings (PlaybackDelaySettings), globally via PhotonVoiceNetwork.Instance.SetGlobalPlaybackDelaySettings / VoiceConnection.SetGlobalPlaybackDelaySettings or individually per Speaker (speaker.SetPlaybackDelaySettings). This can happen from Editor or via code.

Playback delay settings:

  • MinDelaySoft: the lowest bound of target delay: the audio player tries to keep the delay above this value. Default is 200.
  • MaxDelaySoft: upper bound of target delay: audio player tries to keep the delay below this value. Default is 400.
  • MaxDelayHard: audio player guarantees that the delay never exceeds this value. Default is 1000.

Playback behaviour:

  • While the delay is between MinDelaySoft and MaxDelaySoft, nothing happens.
  • if it's between MaxDelaySoft and MaxDelayHard, data is resampled to catch up with the input stream.
  • When the delay > MaxDelayHard, it's just set to target value (the average of MinDelaySoft and MaxDelaySoft, default is (200 + 400) / 2 = 300).

Conditions:

  • 0 <= MinDelaySoft.
  • MaxDelaySoft > MinDelaySoft.
  • if MaxDelayHard <= MaxDelaySoft: in this case no resampling will happen.

Hints:

The idea is to tweak the delay values until you find a good compromise.

  • As a first step disable resampling in playback by setting MaxDelayHard <= MaxDelaySoft. This is important especially for music streaming.
  • To avoid pauses, increase delay because rare pauses can be unnoticed in speech and clearly heard in music.
  • We recommended much higher MinDelaySoft (500-1000ms and adjust MaxDelaySoft accordingly) for music streaming.
  • Another option worth trying: reliable transmission (enabled via Recorder.ReliableMode), YouTube transmits reliably with huge delay, that's why it's as good.
  • You could start with default combination: 200, 400, 1000 then 200, 400, 400 and after that try to increase MinDelaySoft while keeping MaxDelaySoft > MinDelaySoft (double is OK, i.e. MaxDelaySoft = 2 * MinDelaySoft). The step could be 100 ms or 200 ms or even doubling at once, e.g. (200, 400, 400) -> (300, 600, 600) or (400, 800, 800) etc.

If the issue persists:

  • You could try uncommenting //#define USE_ONAUDIOFILTERREAD and see if it helps. This playback method that makes use of Unity's built-in audio pipeline via OnAudioFilterRead callback and does not support 3D positioning.
  • You could also make your own IAudioOut implementation for playback and use it in Speaker.

Android Volume Controls when using Photon Microphone Type

There are four volume sliders on Android:

  • Media volume: Music, videos, games, other media
  • Call volume: Volume of the other person during a call. Available only during calls.
  • Ring volume: Phone calls, notifications.
  • Alarm volume

Depending on audio session mode, the system chooses automatically which slider to assign to hardware buttons. Read more here.

When using Recorder with Photon microphone type, the device is switched to voice call mode to be able to use hardware AEC. In this case volume buttons adjust Call volume. This volume does not affect Unity output which is controlled by Media volume.

You could try to switch to the Media volume slider when changing volume.

You could also use Unity microphone type with WebRtcAudioDsp, it has AEC, NoiseSuppression, AGC and even a better VAD.

unity microphone type - media volume slider
Unity Microphone Type - Media Volume Slider
unity microphone type - volume sliders
Unity Microphone Type - Volume Sliders
photon microphone type - call volume slider
Photon Microphone Type - Call Volume Slider
photon microphone type - volume sliders
Photon Microphone Type - Volume Sliders
Back to top