Hello! I did some stress tests and I think I figured it out what's the real problem.
Before my tests, lag was about 6 seconds, but I found out that the real server lag is around ~1 second, but sending the data through network isn't the real problem. I think is receiving and reproducing it.
First problem
First problem is when WebGL is running on background, it doesn't stop microphone, so when I come back to the player, it starts to send a lot of data that can't be processed in time, and delay start to increase.
I also think that some packages are being lost, and that increases playback time.
Second problem
Second problem is reproducing the received data. I did some tests with a friend of mine and asked her to unmute, send data and mute again. The lag simply dissappeared. Still a little bit higher then Discord, but it's really great. (I've tried with south america server and my Photon ID for tests).
Possible solutions
I think we should try to detect when microphone is quiet to prevent sending unnecessary data. This can decrease the amount of data sent and then also decrease the amount of sound that needs to be played.
Also we should disable microphone detection when WebGL is running on background, because it's definately not working (but I'm not sure if it's possible to fix that, what do you think?)
Last time that I've worked with microphone on Android, I had to reset loading data from it every time that the application was send to background. I still have the code and I think it's the same problem here.
I would love to discuss more about the implementation if you want to, and I'll try to work a little bit on the code to see if I can improve anything.
Hello! I did some stress tests and I think I figured it out what's the real problem.
Before my tests, lag was about 6 seconds, but I found out that the real server lag is around ~1 second, but sending the data through network isn't the real problem. I think is receiving and reproducing it.
First problem
First problem is when WebGL is running on background, it doesn't stop microphone, so when I come back to the player, it starts to send a lot of data that can't be processed in time, and delay start to increase.
I also think that some packages are being lost, and that increases playback time.
Second problem
Second problem is reproducing the received data. I did some tests with a friend of mine and asked her to unmute, send data and mute again. The lag simply dissappeared. Still a little bit higher then Discord, but it's really great. (I've tried with south america server and my Photon ID for tests).
Possible solutions
I think we should try to detect when microphone is quiet to prevent sending unnecessary data. This can decrease the amount of data sent and then also decrease the amount of sound that needs to be played.
Also we should disable microphone detection when WebGL is running on background, because it's definately not working (but I'm not sure if it's possible to fix that, what do you think?) Last time that I've worked with microphone on Android, I had to reset loading data from it every time that the application was send to background. I still have the code and I think it's the same problem here.
I would love to discuss more about the implementation if you want to, and I'll try to work a little bit on the code to see if I can improve anything.