gree / unity-webview

zlib License
2.27k stars 687 forks source link

Unity sound not working after close webview. #1079

Closed Changsoo-UTop closed 3 months ago

Changsoo-UTop commented 3 months ago

Hello. I'm using gree webview for showing Youtube or web E-book contents and It worked great until Android 13. but I tested in Android 14, It worked something weird.

  1. Play background music in Unity.
  2. Open webview with Youtube URL or internal E-book contents on Unity.
  3. Do some interaction to play sound. (Touch unmute button on Youtube web page or touch speaker button for narration on E-Book contents.)
  4. Close webview.
  5. Unity sound is not work. (But It's playing. just can't hearing.)

What can I do for fix this bug?

Thank you.

Changsoo-UTop commented 3 months ago

It only happens in Android 14. and... It could be Audio Focus issue on Android 14..?

KojiNakamaru commented 3 months ago

Based on the sample app, could you please provide a minum project that reproduces the issue? You can attach a zip file here.

Changsoo-UTop commented 3 months ago

APK.zip

Thank you for reply! Here is an APK that can reproduce the issue.

  1. Install APK on device that running Android 14.
  2. Press the "Open webview" Button.
  3. Press unmute button on webview. (This case is Youtube.)
  4. Press the "Close webview" Button which in right-upper side.
  5. Unity sound is gone.
  6. Press home button and launch app from background, Unity sound coming back. (Don't kill app from background.)
Changsoo-UTop commented 3 months ago

SampleProject.zip

And this is I made project to make that APK.

Unity version: 2022.3.31f1 Build: macOS Sonoma 14.5

Changsoo-UTop commented 3 months ago

https://github.com/gree/unity-webview/assets/100737974/bb7494a4-3d80-4341-b4a2-6899d5dc295e

Here is a video.

Device: Samsung Galaxy Z Flip 5

KojiNakamaru commented 3 months ago

Thank you for the archives and the movie. I was able to reproduce the issue on my devices; one was Headwolf FPad5 (Android 14) and another was OSCAL Pad8 (Android 11).

As you mentioned, the cause seems to be related to Audio Focus, but it doesn't depend on Android versions, instead, it depends on Unity versions. The easiest workaround is to turn "Other Settings/Configuration/Mute Other Audio Sources" off.

Changsoo-UTop commented 3 months ago

Oh.. I didn't thought test with "Mute Other Audio Sources"... Thank you so much for testing and answer!