! F: Implement webview reset#142
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR implements webview reset functionality for Android platforms to ensure the webview returns to a clean state when players rejoin after all players have left the game session.
Key changes include:
- Added webview recreation methods that reset internal state and recreate the webview component
- Modified game end handling to trigger cache reset and webview recreation
- Refactored launch app transition handling from synchronous Thread.Sleep to asynchronous coroutine with yield
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
7817807 to
0ef941f
Compare
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
Assets/AirConsole/scripts/Runtime/AirConsole.cs:1
- This event handler cleanup code is duplicated in both
StopWebsocketServer()andCleanupWebSocketListener()methods. Consider extracting this into a separate method likeUnsubscribeWebSocketEvents()to eliminate code duplication.
#if !UNITY_EDITOR && UNITY_ANDROID
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
48d036c to
b8e3fa8
Compare
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
Assets/AirConsole/scripts/Runtime/AirConsole.cs:1
- The _webViewOriginalUrl is being set inside the UNITY_ANDROID compiler directive, but it's used in RecreateWebView method which doesn't have platform-specific guards. This will cause _webViewOriginalUrl to remain null on non-Android platforms, leading to early returns in RecreateWebView.
#if !UNITY_EDITOR && UNITY_ANDROID
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| // Unregister event handlers before stopping to prevent race conditions | ||
| UnsubscribeWebSocketEvents(); |
There was a problem hiding this comment.
UnsubscribeWebSocketEvents() is called before checking if wsListener is null, but UnsubscribeWebSocketEvents() performs a null check on wsListener and returns early if null. This creates redundant null checking and could mask potential issues if wsListener becomes null between the two calls.
There was a problem hiding this comment.
For now, I can only help with PRs you've created.
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
d893968 to
bec91d7
Compare
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
@codex review |
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
| if (Settings.debug.info) { | ||
| AirConsoleLogger.Log(() => "AirConsole: onGameEnd"); | ||
| } | ||
|
|
||
| // Reset all caches | ||
| ResetCaches(); |
There was a problem hiding this comment.
Clearing event queue drops OnGameEnd callback
The new ResetCaches() call clears eventQueue immediately after queuing the onGameEnd delegate. Because ResetCaches() is invoked inside OnGameEnd before the queue is processed on the main thread, the callback that was just enqueued is removed and never reaches user code. This means any screen logic listening for onGameEnd will no longer run when a game ends. Consider clearing caches after pending events have been dispatched (or avoid clearing the queue entirely) so the onGameEnd event still fires.
Useful? React with 👍 / 👎.
…y by removing unnecessary whitespace and consolidating WebSocket event unsubscription logic.
bec91d7 to
e7ccc0a
Compare
a5f495d to
f177de3
Compare
This avoids the situation where RecreateWebView gets executed out of sheer luck because it is in the currently running task, despite that task being cleared from the queue in ResetCaches. The previous implementation would have been hard to maintain without a lot of documentation.
3632c71 to
af2ede1
Compare
|
Codex reviewed in #145 |
This implements Android webview resetting after the last player left to ensure the webview is in the correct state when the Player Lobby reappears and the players decide to start a new round.