Our game is built in UE 4.27.2 for Meta Quest. It uses the EOS OSS for the voice chat feature through lobbies. A problem we are seeing is that when the user chooses to quit the game through the Quest universal menu, the voice chat from the in-game lobby plays for several seconds after the game has closed and the user is back in the Quest home. The audio that plays is choppy during this period of time. Ideally, no sound should be playing at all.
It’s important to note that when the user quits via the universal menu, the game appears to not shut down properly. There is code in LaunchAndroid.cpp that calls AndroidThunkCpp_ForceQuit() when the app receives the APP_CMD_DESTROY from the OS. This appears to shut down the app immediately which does not allow ApplicationWillTerminateDelegate to broadcast. When the call to AndroidThunkCpp_ForceQuit() is commented out, the app does proceed into the shutdown process and ApplicationWillTerminateDelegate is broadcast. However, it appears that after about 0.5 seconds the OS kills the game in the middle of the shutdown. At least, the logs end abruptly at that point.
We have hooked into ApplicationWillTerminateDelegate in an attempt to explicitly leave the lobby, but this did not fix the audio issue. We also call FEOSVoiceChat::Disconnect() and FEOSVoiceChat::Uninitialize(), but that did not resolve the issue either. In fact, FEOSVoiceChat::IsConnected() returns false before the attempt to disconnect.
My hypothesis is that EOS is spawning some child process that is not immediately terminated when the game itself is terminated because the game is not completing the shutdown process. Is there a way to allow the game to shut down completely before being killed by the OS? Or alternatively, how do we stop EOS from processing the voice chat?
I wanted to provide an update with more information.
I in the callback for the ApplicationWillTerminateDelegate, I tried to call Logout() on the player’s IVoiceChatUser. At first that seemed to work because the voice chat did stop when the player quits. However, it turns out that this was in a Development build where an assert was triggered. Apparently, it ended up calling FOnlineSubsystemEOSVoiceChatUserWrapper::Logout() which is not allowed.
I also tried calling both SetAudioInputDeviceMuted(true) and SetAudioOutputDeviceMuted(true) on the IVoiceChatUser. These function calls work during normal gameplay if the user changes his or her in-game settings, but unfortunately this did not stop the voice chat upon quitting the game.
After combing through the full logcat text, I noticed that there is actually a log from the ActivityTaskManager indicating that it is killing the game activity due to a destroy timeout. This comes with a line about the activity’s process ID being killed. These notifications come about 9 seconds after the last output from the UE4 log, and they seem to coincide with the time that the voice chat lingers after returning to the Meta home. This raises questions about what exactly is happening when the player quits the game. Why does the UE4 log abruptly end well before the process is killed - and why does the game not shut down fully? Is the engine itself taking action to stop processing certain threads, or is the OS doing something at that point? Any light that could be shed on this situation would be greatly appreciated.