Unity phone voice bug on android permissions


Every time I update Photon Voice I have to fix the same thing. Here is the situation, if you add a Recorder into unity game object, even if it is not initialized, or started or used, your android game will immediately display the "permission" popup.

This is horrible, because someone that downloads your game for the first time and maybe doesn't want to use the mic, will get a blocking popup asking if they want to be recorded while using your game.

Obviously, most people just freak out and leave a nasty review.

Where is the bug?

Well, the problem is the method in Recorder.cs CheckIfThereIsAtLeastOneMic gets called and you will get an instant popup. How on earth does that get called even if you recorder is not initiated or started?

Because the wonderful method:

internal void CheckAndAutoStart(bool autoStartFlag)

This method has a bunch of cascading "ifs" that get called one after the other. If you enable the log, you will see that every condition is checked and then it goes to the next one and the next one... until it arrives to CheckIfThereIsAtLeastOneMic and also checks it.

This method is so bad, I don't understand why it hasn't been fixed. You should do a simple

if (condition) {

} else if (condition) {


so that it would never CheckIfThereIsAtLeastOneMic if any condition is matched, but there is no "else" anywhere, so it just keeps going through every single "if".

Please fix this


  • vadim


    Thanks for the report. Of course, the application should not ask for the permission if it's not required.

    We will look into this. If you have a solution already, please share it with us. It may help.

    Why is there a Recorder in the scene of the app which does not use the mic? Can you workaround this by simply removing the Recorder?

  • creat326

    No you can't workaround this by simply removing the recorder. The app is using the mic and is using the recorder. But at the request of the user.

    What I mean, is that the option to press the "mic" button is there and therefore the Recorder class is in the scene. But it is optional. The person may choose not to ever press the mic button.

    The issue is that the moment you include the Recorder into the scene, it will ask for android permissions, even if that person did not press the mic button or has any intention of using it.

    The Recorder is going through every single "if" and one of them checks if the mic is in use. The moment it hits that line, you will get an android popup asking if you want to give access to the recorder. From the player's point of view, he just entered the game, he has not pressed the mic button, why do you want to record him?

    By changing it to if/else, it fixes it. Because the first if checks if you initialized the recorder, and you didn't because nobody is trying to record. So it will skip all the steps and quit checking.

  • chuckyw

    Thank you for the report, we will fix this in one of next releases.