Integrate native audio focus and webview reload support#151
Integrate native audio focus and webview reload support#151marc-n-dream merged 11 commits intomasterfrom
Conversation
…ve for topbar vs fullscreen event flows
…cleanup when unnecessary
|
@codex review |
There was a problem hiding this comment.
Pull request overview
This PR integrates native audio focus management and webview reload support to improve Android platform behavior, particularly for Android Automotive. Key changes include implementing thread-safe event handling for WebView callbacks, adding audio focus state management with volume control, and replacing webview recreation with reload-based navigation.
Key Changes:
- Introduced thread-safe event queue architecture for WebView callbacks to handle cross-thread communication from native Android code
- Added native audio focus management with maximum volume tracking to comply with Android Automotive requirements
- Replaced full webview recreation with reload-based navigation to improve performance and reliability
Reviewed changes
Copilot reviewed 35 out of 50 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| CHANGELOG.md | Updated with Android support improvements and audio focus enhancements |
| Assets/WebGLTemplates/AirConsole-U6/airconsole-unity-plugin.js | Added Android TV detection workaround for native game sizing |
| Assets/AirConsole/unity-webview/Runtime/WebViewObject.cs | Implemented thread-safe event queue and removed polling-based message retrieval |
| Assets/AirConsole/unity-webview/Runtime/WebViewEvent.cs | New event model for thread-safe WebView communication |
| Assets/AirConsole/unity-webview/Runtime/WebViewCallback.cs | New direct callback bridge from Java to C# |
| Assets/AirConsole/scripts/Runtime/AirConsole.cs | Added audio focus management and OnGameAudioFocusChanged event |
| Assets/AirConsole/scripts/Runtime/Plugin/Android/PluginManager.cs | Added volume and audio focus change event handlers |
| Assets/AirConsole/scripts/Editor/BuildAutomation/AndroidGradleProcessor.cs | Refactored dependency injection logic |
| Assets/AirConsole/examples/basic/AudioManager.cs | New example showing proper audio focus handling |
| Assets/Packager/Editor/Packager.cs | Removed webview package extraction logic |
| AGENTS.md | Added comprehensive project documentation for AI agents |
Files not reviewed (2)
- .idea/.idea.airconsole-unity-plugin/.idea/codeStyles/Project.xml: Language not supported
- .idea/.idea.airconsole-unity-plugin/.idea/codeStyles/codeStyleConfig.xml: Language not supported
Comments suppressed due to low confidence (1)
Assets/AirConsole/scripts/Editor/BuildAutomation/AndroidGradleProcessor.cs:95
- Using target-typed new expression 'new()' requires C# 9.0 or later. Verify that the project's C# language version is configured to support this syntax to avoid compilation errors in older Unity versions.
List<string> lines = new();
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| case "NATIVE_AUDIOFOCUS_LOSS": | ||
| AirConsoleLogger.Log(() => | ||
| $"{command}: Can ignore native loss={_canIgnoreNativeAudioLoss}"); | ||
|
|
||
| if (_canIgnoreNativeAudioLoss) { |
There was a problem hiding this comment.
Update HasAudioFocus when native focus is lost
In the native audio focus loss branch the code logs and conditionally returns but never sets HasAudioFocus to false, even though the gain branches above set it to true. When Android delivers NATIVE_AUDIOFOCUS_LOSS (e.g., another app grabs audio), the API property remains true despite focus having been revoked, so game code that relies on HasAudioFocus will keep playing sound after a loss unless it separately tracks the event argument.
Useful? React with 👍 / 👎.
a5501eb to
c558666
Compare
No description provided.