MicrophoneType: Photon not working on ANDROID

Alex_H
Alex_H
edited February 2020 in Photon Voice
The issue now is that in Android with Unity 2019.2.9f1 the Photon Microphonetype does not work. My original post had an issue about rejoining rooms that has been solved (see below).

ORIGINAL POST:


Same issue that has been found before but different error?. Microphone works well on first join but after exiting and rejoining room it has a lot of issues connecting and working. When looking from the editor project I can see that the client state (in PhotonVoiceNetwork) changes from "Joining" to "ConnectingToMasterserver" and the current server address keeps changing:

gwei4PT.png

Comments

  • Alex_H
    Alex_H
    edited February 2020
    Ok so this is what I get when it works (first time connecting) in the logs:

    BpfPsBK.png

    and the following after disconnecting and trying to rejoin:

    GhK3Q8E.png


    Sometimes after a looong time it actually joins and it starts working
  • Alright latest news, seems to be that when unchecking "Use PUN's App settings" in PhotonVoiceNetwork and just adding the settings to the PhotonVoiceNetwork component then everything seems to work well.
  • Alex_H
    Alex_H
    edited February 2020
    I also changed the MicrophoneType to Photon to test and it does not work with Android builds, any idea why it might be?

    Everything is fine with Unity type
  • Alright so when checking the GameObject with the photonvoice corresponding to the android device from the Unity project I see this flat:

    donBeH8.png

    As opposed to seeing the waves when some other client with audio works. This also only happens when having Photon MicrophoneType everything is fine with Unity type
  • JohnTube
    JohnTube ✭✭✭✭✭
    Hi @Alex_H,

    You are reporting two different issues:

    1. Rejoin or switch rooms issue: fixed in 2.13

    Rejoining rooms with "Use PUN's App Settings" checked should work as expected.
    We tested this and we have customers who tested this.
    Just make sure to update to latest version (2.13) properly.

    2. Android issue with MicrophoneType Photon:

    Increase log levels of the Voice components (not only PhotonVoiceNetwork) and check the logs.
  • 1.Yes I left the original post for information. I am in version 2.13 and it doesn't rejoin properly unless I uncheck "Use PUN's App Settings" and set my settings by hand. Setting the Id by hand and the rest of info (I am using a region specifically "us") then it rejoins no issue (I am also using a different appID for voice and PUN, this might be relevant).

    2. The current issue with Android seems to be that the MicrophoneType: Photon simply doesn't work when I deploy a build on device, everything is perfectly fine under MicrophoneType: Unity. To be more specific I tried deploying to several different android devices and created rooms with them in it and I checked logs from the PC (Unity project in Play mode), everything seems fine but I get no audio from the android clients (on android devices). The picture of the flat speaker is from play mode and corresponds to the android users' prefabs that own the PhotonVoiceView as seen by the client from the PC.
  • JohnTube
    JohnTube ✭✭✭✭✭
    1. Not sure why it does not work for you. Having separate AppIDs is not relevant (it's the expected way). Setting an explicit region is also not relevant. Maybe your PhotonVoiceNetwork.AutoConnectAndJoin or PhotonVoiceNetwork.AutoDisconnectAndLeave are not set to true? or maybe you join and leave voice rooms, explicitly via code.

    2. What Android devices & OS versions did you test this with? What Unity version? did you make sure to have the Android libs required? No errors from Recorder component?
  • Alex_H
    Alex_H
    edited February 2020
    1. Both are set to true, and I don't join voice rooms as I simply let PUN create the room and transition to the scene where the PhotonVoiceNetwork is in. I also have tried removing the GameObject with the PhotonVoiceNetwork (since its loaded as DontdestroyonLoad) when exiting a room so it's all clean when re-entering the scene, and it still fails.

    2. No errors from the recorder of the client in the PC (from the unity project I don't have the android device connected but I should probably try that see if I get any logs). I tried with Galaxy Note 9 with Android 9 and a Huawei P20 with Android 9 as well. Unity version is 2019.2.9f1. As for the Android libs are you referring to the libopus libraries in Photon Voice?

  • JohnTube
    JohnTube ✭✭✭✭✭
    edited February 2020
    1. Weird. Maybe you are using the same UserId from different players which prevents the client from joining?
    2. libopus libs yes.
  • Libs are there, I will get back to this issue in a couple weeks and try to debug better, we are using unity type microphone with AEC for now, but I definitely want to get the native microphone working. I will report once I am back to it.
  • Alex_H
    Alex_H
    edited March 2020
    Alright I have fixed the issues of no sound in Android I had by adding a recorder to my objects with the photonview on them. The recorder placed in the scene that I was using before and that it was used as a primary recorder would not work properly, it might be a race condition of sorts I guess since my objects with photonview were instantiated by PUN. Now the photon voice view, the photon view and recorder are all in the same gameobject.

    I have this cross platform working, with MicrophoneType Photon in both IOS and Android, I had to do the fixes for the speaker in IOS but it works well.

    The only issue I have now is that the volume coming from the Android microphone is really low (IOS is fine) and it actually produces echo in users from IOS. So the culprit is the android voice and microphone ( I can tell by muting android and using only IOS users. When android is muted, there is no echo), it is as if it wasn't using native echo cancellation and capabilities in android. I tested this with a Galaxy Note 9. Any ideas?
  • Thanks for documenting your progress here, I'm struggling with MicType Photon issues too. In my case, Photon doesn't work on Windows both in the editor and standalone. Voice View connects just fine using PUN settings, and recorders and speakers also get set up just fine, there's just no audio being picked up by the Photon mic. The Level property on the Recorder stays at 0 despite talking into the mic, whereas on MicType Unity the Level changes when speaking into the mic and the other player can hear it fine.

    I've switched to Unity for now but I too would prefer using Photon because of the echo cancelation etc.
  • @Alex_H, Can you provide us with the device logs? We are interested in lines starting from "[PV]". They have info on whether echo cancellation is available on device mic. Is there only 1 microphone in Galaxy Note 9?

    @Stefferp, what type of microphone (device name) your machine has? In case of multiple microphones make sure that correct microphone is selected. It would be interesting to look at logs too.

    To workaround Photon mic issue on Windows, Mac, iOS and Android:
    Add WebRTC Audio DSP component to a prefab with Recorder and choose Unity microphone type. This component is able to make several audio enhancements including echo cancellation and automatic gain control.
  • Alex_H
    Alex_H
    edited March 2020
    Here are the logs with [PV]:

    03-10 10:23:55.062 20286 20302 I [PV] AudioInAEC: AudioRecord created: android.media.AudioRecord@4873d6f: samplingRate: 44100, channels: 1, recordBufSizeBytes: 14336, enableAEC: true

    03-10 10:23:55.065 20286 20302 I [PV] AudioInAEC: AcousticEchoCanceler created: android.media.audiofx.AcousticEchoCanceler@5272a7c, setEnabled res: 0: true -> true

    03-10 10:23:55.074 20286 20302 I [PV] AudioInAEC: NoiseSuppressor created: android.media.audiofx.NoiseSuppressor@8870f05, setEnabled res: 0: false -> true

    03-10 10:23:55.134 20286 21768 I [PV] AudioInAEC: thread start

    03-10 10:23:55.168 20286 20302 I [PV] AudioInAEC: AudioRecord buffer set, size: 882

    03-10 10:29:52.071 20286 21768 I [PV] AudioInAEC: thread stop

    Also I sent you an email with the textfile with the logs

    Also it seems there are 8 mics in galaxy note 9

    I just tried with another android device (Huawei P20) and it was working properly.
  • According to log, Automatic Gain Control is not available on this device, AutomaticGainControl.isAvailable() call returns false. This is weird. Maybe try to reset the device?
  • Mmmm, reset did not fix it. The mic and automaticgain seems to work fine in all native apps (whatsapp, skype, etc).
  • Did you try WebRTC Audio DSP and Unity microphone type? Unity definitely better supports a variety of audio input devices.
  • I did but the echo and gain control stuff wasn't very good. It is really fantastic when it properly works with MicrophoneType Photon and you get all the native stuff