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.
Mobile Background Apps
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.).
If the app stays paused for more than the client disconnect timeout (which should be 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 when the app is no longer in the background.
If the game design can allow a player to return even 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
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
}
}
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 this network resource
Make sure to enable the required capability from Unity's "Player Settings" -> "Publisher Settings" -> "Capabilities -> "InternetClient"
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:
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).
Asset Store Package Update
Sometimes assets are not updated at all or not updated properly from the Assset Store in some Unity versions.
Always verify Photon packages' versions either from the change log txt files or from PhotonServerSettings for PUN.
This is a known Unity issue, sometimes old packages are stuck in the local offline cache and updates do not occur at all or not properly.
To fix this, remove the Photon asset package locally first and try downloading / importing again.
The paths for the local Unity assets store cache folder are listed here.
Photon Voice
Android 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:
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
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.
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:
- If you are using Photon Voice 1 upgrade to Photon Voice 2.
- Use Photon as Recorder.MicrophoneType.
- 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". - 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.
WebGL Support
WebGL is not a supported platform for the following reasons:
- WebGL does not work well with threads and we use those in Photon Voice for encoding and decoding.
- Unity Microphone does not work in WebGL.
- We need an Opus codecs library build that works with WebGL.
- Photon for WebGL supports WebSocketSecure protocol only.
Photon Voice works better using UDP.
For all these reasons we decided to drop support for the WebGL platform.
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 totrue
. - 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:
- use Photon microphone type.
- 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.
- 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
andMaxDelaySoft
, nothing happens. - if it's between
MaxDelaySoft
andMaxDelayHard
, data is resampled to catch up with the input stream. - When the delay >
MaxDelayHard
, it's just set to target value (the average ofMinDelaySoft
andMaxDelaySoft
, 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 adjustMaxDelaySoft
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 keepingMaxDelaySoft
>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 viaOnAudioFilterRead
callback and does not support 3D positioning. - You could also make your own
IAudioOut
implementation for playback and use it inSpeaker
.
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
- ArgumentException in Socket.SetSocketOption
- Unity 2018.2 Sockets Freeze with .Net 4.x
- RunInBackground
- Windows Store Capabilities
- UWP Exports
- iOS IPv6
- Asset Store Package Update
- Photon Voice
- Android Microphone Permission
- iOS Microphone Permission
- macOS Microphone Permission
- Unity Microphone Issues
- Frequency Warnings
- Native Library Updates
- Android 64-bit Support
- iOS Speaker Issue
- iOS Silent/Ring Switch and Muting
- WebGL Support
- Oculus OVR SDK
- Echo or Noise
- Low Volume
- High Pitch
- Android Volume Controls when using Photon Microphone Type