Skip to content

! F: Implement webview reset#142

Merged
marc-n-dream merged 11 commits intoAirConsole:masterfrom
dreamora:marc-webview-reset
Oct 12, 2025
Merged

! F: Implement webview reset#142
marc-n-dream merged 11 commits intoAirConsole:masterfrom
dreamora:marc-webview-reset

Conversation

@dreamora
Copy link
Contributor

@dreamora dreamora commented Oct 9, 2025

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.

Copilot AI review requested due to automatic review settings October 9, 2025 23:23
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@dreamora dreamora force-pushed the marc-webview-reset branch from 7817807 to 0ef941f Compare October 9, 2025 23:42
@dreamora dreamora requested a review from Copilot October 9, 2025 23:47
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@dreamora dreamora requested a review from Copilot October 9, 2025 23:54
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@dreamora dreamora requested a review from Copilot October 9, 2025 23:55
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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() and CleanupWebSocketListener() methods. Consider extracting this into a separate method like UnsubscribeWebSocketEvents() 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.

@dreamora dreamora force-pushed the marc-webview-reset branch from 48d036c to b8e3fa8 Compare October 9, 2025 23:58
@dreamora dreamora requested a review from Copilot October 9, 2025 23:59
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@dreamora dreamora requested a review from Copilot October 10, 2025 00:14
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +1900 to +1901
// Unregister event handlers before stopping to prevent race conditions
UnsubscribeWebSocketEvents();
Copy link

Copilot AI Oct 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now, I can only help with PRs you've created.

@dreamora dreamora requested a review from Copilot October 10, 2025 00:29
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@dreamora dreamora requested a review from Copilot October 10, 2025 00:31
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@marc-n-dream
Copy link
Collaborator

@codex review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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

Comment on lines 1552 to 1663
if (Settings.debug.info) {
AirConsoleLogger.Log(() => "AirConsole: onGameEnd");
}

// Reset all caches
ResetCaches();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

@AirConsole AirConsole deleted a comment from chatgpt-codex-connector bot Oct 12, 2025
…y by removing unnecessary whitespace and consolidating WebSocket event unsubscription logic.
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.
@marc-n-dream
Copy link
Collaborator

Codex reviewed in #145

@marc-n-dream marc-n-dream merged commit f23fd4f into AirConsole:master Oct 12, 2025
2 checks passed
@dreamora dreamora deleted the marc-webview-reset branch October 14, 2025 20:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants