[iOS] Safety Checks To Avoid Gemini Calls After SceneDidDisconnect [chromium/src : main]

0 views
Skip to first unread message

Scott Yoder (Gerrit)

unread,
Mar 20, 2026, 11:07:29 AM (3 days ago) Mar 20
to Joemer Ramos, Gauthier Ambard, Adam Arcaro, Chromium LUCI CQ, chromium...@chromium.org, ios-revie...@chromium.org, ios-r...@chromium.org, marq+...@chromium.org
Attention needed from Gauthier Ambard and Joemer Ramos

Scott Yoder voted and added 3 comments

Votes added by Scott Yoder

Code-Review+1

3 comments

Patchset-level comments
File ios/chrome/browser/scene/coordinator/scene_coordinator.mm
Line 246, Patchset 9: _viewController.geminiHandler = HandlerForProtocol(
_regularBrowser->GetCommandDispatcher(), BWGCommands);
Scott Yoder . resolved

Does this work? SceneCoordinator gets started very early, so I would be surprised if BWGCommands handler is already available. We probably need to somehow access the handler at the time that it is needed.

Joemer Ramos

I tested locally and it looks like it works...which might make sense? I copy pasted the logic from `TabGridViewController` and if that was the legacy rootViewController and [setting geminiHandler](https://source.chromium.org/chromium/chromium/src/+/main:ios/chrome/browser/tab_switcher/ui_bundled/tab_grid/tab_grid_coordinator.mm;l=979-980) worked there, maybe it works here too. Feel free to close this out after reading/if you agree.

Scott Yoder

After searching through the code I see that BWGCommands is dispatched to the BrowserCoordinator, which is instantiated in the BrowserLifecycleManager before SceneCoordinator is started. So agree, this should be ok. If this wasn't ok, HandlerForProtocol() would crash and I think that would show up pretty quickly in EG tests.

File ios/chrome/browser/scene/ui/scene_view_controller.mm
Line 238, Patchset 10: if (!self.geminiHandler) {
return;
}
Scott Yoder . unresolved

You don't need to nil check it, the command will just not be dispatched below if it is nil anyway.

Open in Gerrit

Related details

Attention is currently required from:
  • Gauthier Ambard
  • Joemer Ramos
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is blockingCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Ic7554e6e14bb5e265d2cabf3c8a18d4af58497b3
Gerrit-Change-Number: 7669564
Gerrit-PatchSet: 12
Gerrit-Owner: Joemer Ramos <joeme...@google.com>
Gerrit-Reviewer: Adam Arcaro <ada...@google.com>
Gerrit-Reviewer: Gauthier Ambard <gam...@chromium.org>
Gerrit-Reviewer: Joemer Ramos <joeme...@google.com>
Gerrit-Reviewer: Scott Yoder <scott...@google.com>
Gerrit-Attention: Joemer Ramos <joeme...@google.com>
Gerrit-Attention: Gauthier Ambard <gam...@chromium.org>
Gerrit-Comment-Date: Fri, 20 Mar 2026 15:07:23 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: Joemer Ramos <joeme...@google.com>
Comment-In-Reply-To: Scott Yoder <scott...@google.com>
satisfied_requirement
unsatisfied_requirement
blocking_requirement
open
diffy

Joemer Ramos (Gerrit)

unread,
Mar 20, 2026, 11:09:25 AM (3 days ago) Mar 20
to Joemer Ramos, Scott Yoder, Gauthier Ambard, Adam Arcaro, Chromium LUCI CQ, chromium...@chromium.org, ios-revie...@chromium.org, ios-r...@chromium.org, marq+...@chromium.org
Attention needed from Gauthier Ambard

Joemer Ramos added 1 comment

File ios/chrome/browser/scene/ui/scene_view_controller.mm
Line 238, Patchset 10: if (!self.geminiHandler) {
return;
}
Scott Yoder . resolved

You don't need to nil check it, the command will just not be dispatched below if it is nil anyway.

Joemer Ramos

Yeah thats what i thought too, but i was looking at minicrash dumps and it still looks like it was trying to call geminiHandler. I think maybe the <id> wasn't being cleaned up properly, but generally I agree so removing.

Open in Gerrit

Related details

Attention is currently required from:
  • Gauthier Ambard
Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is blockingCode-Review
    • requirement satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Ic7554e6e14bb5e265d2cabf3c8a18d4af58497b3
    Gerrit-Change-Number: 7669564
    Gerrit-PatchSet: 14
    Gerrit-Owner: Joemer Ramos <joeme...@google.com>
    Gerrit-Reviewer: Adam Arcaro <ada...@google.com>
    Gerrit-Reviewer: Gauthier Ambard <gam...@chromium.org>
    Gerrit-Reviewer: Joemer Ramos <joeme...@google.com>
    Gerrit-Reviewer: Scott Yoder <scott...@google.com>
    Gerrit-Attention: Gauthier Ambard <gam...@chromium.org>
    Gerrit-Comment-Date: Fri, 20 Mar 2026 15:09:19 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Scott Yoder <scott...@google.com>
    satisfied_requirement
    unsatisfied_requirement
    blocking_requirement
    open
    diffy

    Gauthier Ambard (Gerrit)

    unread,
    Mar 20, 2026, 12:52:00 PM (3 days ago) Mar 20
    to Joemer Ramos, Scott Yoder, Adam Arcaro, Chromium LUCI CQ, chromium...@chromium.org, ios-revie...@chromium.org, ios-r...@chromium.org, marq+...@chromium.org
    Attention needed from Joemer Ramos

    Gauthier Ambard voted and added 1 comment

    Votes added by Gauthier Ambard

    Code-Review+0

    1 comment

    File ios/chrome/browser/scene/ui/scene_view_controller.mm
    Line 243, Patchset 14 (Latest): UISceneActivationStateForegroundActive) {
    Gauthier Ambard . unresolved

    How does that work when the scene is in background? I don't have a clear flow in mind, but let's assume you are on iPad with several scenes. This is called on a background scene. Is it ok to early return?

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Joemer Ramos
    Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement is not satisfiedCode-Owners
      • requirement satisfiedCode-Review
      • requirement is not satisfiedNo-Unresolved-Comments
      • requirement satisfiedReview-Enforcement
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: chromium/src
      Gerrit-Branch: main
      Gerrit-Change-Id: Ic7554e6e14bb5e265d2cabf3c8a18d4af58497b3
      Gerrit-Change-Number: 7669564
      Gerrit-PatchSet: 14
      Gerrit-Owner: Joemer Ramos <joeme...@google.com>
      Gerrit-Reviewer: Adam Arcaro <ada...@google.com>
      Gerrit-Reviewer: Gauthier Ambard <gam...@chromium.org>
      Gerrit-Reviewer: Joemer Ramos <joeme...@google.com>
      Gerrit-Reviewer: Scott Yoder <scott...@google.com>
      Gerrit-Attention: Joemer Ramos <joeme...@google.com>
      Gerrit-Comment-Date: Fri, 20 Mar 2026 16:51:41 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: Yes
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Joemer Ramos (Gerrit)

      unread,
      Mar 20, 2026, 1:16:44 PM (3 days ago) Mar 20
      to Joemer Ramos, Scott Yoder, Gauthier Ambard, Adam Arcaro, Chromium LUCI CQ, chromium...@chromium.org, ios-revie...@chromium.org, ios-r...@chromium.org, marq+...@chromium.org
      Attention needed from Gauthier Ambard

      Joemer Ramos added 1 comment

      File ios/chrome/browser/scene/ui/scene_view_controller.mm
      Line 243, Patchset 14 (Latest): UISceneActivationStateForegroundActive) {
      Gauthier Ambard . unresolved

      How does that work when the scene is in background? I don't have a clear flow in mind, but let's assume you are on iPad with several scenes. This is called on a background scene. Is it ok to early return?

      Joemer Ramos

      I'm not sure how `dismissViewControllerAnimated:completion:` can be called while a scene is in the background **and** foregroundActive. Maybe @scott...@google.com knows?

      But for Gemini context, there is only one Gemini floaty instance and this command dispatch call gets sent to `GeminiBrowserAgent` (which is browser/window bound). So if there's other scenes, even if they remain active and this function is called, the Gemini floaty being invoked would be taken into account on the browser level and would likely early return if the floaty wasn't invoked in that window. If the floaty **was** invoked in that background scene and somehow passed the `UISceneActivationStateForegroundActive` check, then I suppose the Gemini floaty would show.

      In any case, if we early return in this function, the worst case scenario is that the floaty doesn't reappear when expected, and on the next scroll event (not in this CL), the floaty will reappear for the user.

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Gauthier Ambard
      Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement is not satisfiedCode-Owners
      • requirement satisfiedCode-Review
      • requirement is not satisfiedNo-Unresolved-Comments
      • requirement satisfiedReview-Enforcement
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: chromium/src
      Gerrit-Branch: main
      Gerrit-Change-Id: Ic7554e6e14bb5e265d2cabf3c8a18d4af58497b3
      Gerrit-Change-Number: 7669564
      Gerrit-PatchSet: 14
      Gerrit-Owner: Joemer Ramos <joeme...@google.com>
      Gerrit-Reviewer: Adam Arcaro <ada...@google.com>
      Gerrit-Reviewer: Gauthier Ambard <gam...@chromium.org>
      Gerrit-Reviewer: Joemer Ramos <joeme...@google.com>
      Gerrit-Reviewer: Scott Yoder <scott...@google.com>
      Gerrit-Attention: Gauthier Ambard <gam...@chromium.org>
      Gerrit-Comment-Date: Fri, 20 Mar 2026 17:16:37 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      Comment-In-Reply-To: Gauthier Ambard <gam...@chromium.org>
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Scott Yoder (Gerrit)

      unread,
      Mar 20, 2026, 2:42:23 PM (3 days ago) Mar 20
      to Joemer Ramos, Gauthier Ambard, Adam Arcaro, Chromium LUCI CQ, chromium...@chromium.org, ios-revie...@chromium.org, ios-r...@chromium.org, marq+...@chromium.org
      Attention needed from Gauthier Ambard and Joemer Ramos

      Scott Yoder voted and added 1 comment

      Votes added by Scott Yoder

      Code-Review+1

      1 comment

      File ios/chrome/browser/scene/ui/scene_view_controller.mm
      Line 243, Patchset 14 (Latest): UISceneActivationStateForegroundActive) {
      Gauthier Ambard . unresolved

      How does that work when the scene is in background? I don't have a clear flow in mind, but let's assume you are on iPad with several scenes. This is called on a background scene. Is it ok to early return?

      Joemer Ramos

      I'm not sure how `dismissViewControllerAnimated:completion:` can be called while a scene is in the background **and** foregroundActive. Maybe @scott...@google.com knows?

      But for Gemini context, there is only one Gemini floaty instance and this command dispatch call gets sent to `GeminiBrowserAgent` (which is browser/window bound). So if there's other scenes, even if they remain active and this function is called, the Gemini floaty being invoked would be taken into account on the browser level and would likely early return if the floaty wasn't invoked in that window. If the floaty **was** invoked in that background scene and somehow passed the `UISceneActivationStateForegroundActive` check, then I suppose the Gemini floaty would show.

      In any case, if we early return in this function, the worst case scenario is that the floaty doesn't reappear when expected, and on the next scroll event (not in this CL), the floaty will reappear for the user.

      Scott Yoder
      `dismissViewControllerAnimated:` gets called in two places:
      1. when a modal view is dismissed, generally in response to a user action of some sort. This is probably most likely to happen while the scene is in the foreground because the user wouldn't be interacting with a background scene. (Please correct me if I'm wrong about this).
      2. When the scene is disconnected

      I think Floaty only needs the opportunity to reappear in scenario 1 above.
      Open in Gerrit

      Related details

      Attention is currently required from:
      • Gauthier Ambard
      • Joemer Ramos
      Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement is not satisfiedCode-Owners
      • requirement satisfiedCode-Review
      • requirement is not satisfiedNo-Unresolved-Comments
      • requirement satisfiedReview-Enforcement
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: chromium/src
      Gerrit-Branch: main
      Gerrit-Change-Id: Ic7554e6e14bb5e265d2cabf3c8a18d4af58497b3
      Gerrit-Change-Number: 7669564
      Gerrit-PatchSet: 14
      Gerrit-Owner: Joemer Ramos <joeme...@google.com>
      Gerrit-Reviewer: Adam Arcaro <ada...@google.com>
      Gerrit-Reviewer: Gauthier Ambard <gam...@chromium.org>
      Gerrit-Reviewer: Joemer Ramos <joeme...@google.com>
      Gerrit-Reviewer: Scott Yoder <scott...@google.com>
      Gerrit-Attention: Joemer Ramos <joeme...@google.com>
      Gerrit-Attention: Gauthier Ambard <gam...@chromium.org>
      Gerrit-Comment-Date: Fri, 20 Mar 2026 18:42:16 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: Yes
      Comment-In-Reply-To: Joemer Ramos <joeme...@google.com>
      Comment-In-Reply-To: Gauthier Ambard <gam...@chromium.org>
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Joemer Ramos (Gerrit)

      unread,
      Mar 20, 2026, 3:14:33 PM (3 days ago) Mar 20
      to Joemer Ramos, Scott Yoder, Gauthier Ambard, Adam Arcaro, Chromium LUCI CQ, chromium...@chromium.org, ios-revie...@chromium.org, ios-r...@chromium.org, marq+...@chromium.org
      Attention needed from Gauthier Ambard and Scott Yoder

      Joemer Ramos added 1 comment

      File ios/chrome/browser/scene/ui/scene_view_controller.mm
      Line 243, Patchset 14 (Latest): UISceneActivationStateForegroundActive) {
      Gauthier Ambard . unresolved

      How does that work when the scene is in background? I don't have a clear flow in mind, but let's assume you are on iPad with several scenes. This is called on a background scene. Is it ok to early return?

      Joemer Ramos

      I'm not sure how `dismissViewControllerAnimated:completion:` can be called while a scene is in the background **and** foregroundActive. Maybe @scott...@google.com knows?

      But for Gemini context, there is only one Gemini floaty instance and this command dispatch call gets sent to `GeminiBrowserAgent` (which is browser/window bound). So if there's other scenes, even if they remain active and this function is called, the Gemini floaty being invoked would be taken into account on the browser level and would likely early return if the floaty wasn't invoked in that window. If the floaty **was** invoked in that background scene and somehow passed the `UISceneActivationStateForegroundActive` check, then I suppose the Gemini floaty would show.

      In any case, if we early return in this function, the worst case scenario is that the floaty doesn't reappear when expected, and on the next scroll event (not in this CL), the floaty will reappear for the user.

      Scott Yoder
      `dismissViewControllerAnimated:` gets called in two places:
      1. when a modal view is dismissed, generally in response to a user action of some sort. This is probably most likely to happen while the scene is in the foreground because the user wouldn't be interacting with a background scene. (Please correct me if I'm wrong about this).
      2. When the scene is disconnected

      I think Floaty only needs the opportunity to reappear in scenario 1 above.
      Joemer Ramos

      Yes that is all correct

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Gauthier Ambard
      • Scott Yoder
      Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement is not satisfiedCode-Owners
      • requirement satisfiedCode-Review
      • requirement is not satisfiedNo-Unresolved-Comments
      • requirement satisfiedReview-Enforcement
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: chromium/src
      Gerrit-Branch: main
      Gerrit-Change-Id: Ic7554e6e14bb5e265d2cabf3c8a18d4af58497b3
      Gerrit-Change-Number: 7669564
      Gerrit-PatchSet: 14
      Gerrit-Owner: Joemer Ramos <joeme...@google.com>
      Gerrit-Reviewer: Adam Arcaro <ada...@google.com>
      Gerrit-Reviewer: Gauthier Ambard <gam...@chromium.org>
      Gerrit-Reviewer: Joemer Ramos <joeme...@google.com>
      Gerrit-Reviewer: Scott Yoder <scott...@google.com>
      Gerrit-Attention: Scott Yoder <scott...@google.com>
      Gerrit-Attention: Gauthier Ambard <gam...@chromium.org>
      Gerrit-Comment-Date: Fri, 20 Mar 2026 19:14:26 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      Comment-In-Reply-To: Joemer Ramos <joeme...@google.com>
      Comment-In-Reply-To: Scott Yoder <scott...@google.com>
      Comment-In-Reply-To: Gauthier Ambard <gam...@chromium.org>
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Gauthier Ambard (Gerrit)

      unread,
      10:12 AM (8 hours ago) 10:12 AM
      to Joemer Ramos, Scott Yoder, Adam Arcaro, Chromium LUCI CQ, chromium...@chromium.org, ios-revie...@chromium.org, ios-r...@chromium.org, marq+...@chromium.org
      Attention needed from Joemer Ramos and Scott Yoder

      Gauthier Ambard voted and added 1 comment

      Votes added by Gauthier Ambard

      Code-Review+1

      1 comment

      File ios/chrome/browser/scene/ui/scene_view_controller.mm
      Line 243, Patchset 14 (Latest): UISceneActivationStateForegroundActive) {
      Gauthier Ambard . unresolved

      How does that work when the scene is in background? I don't have a clear flow in mind, but let's assume you are on iPad with several scenes. This is called on a background scene. Is it ok to early return?

      Joemer Ramos

      I'm not sure how `dismissViewControllerAnimated:completion:` can be called while a scene is in the background **and** foregroundActive. Maybe @scott...@google.com knows?

      But for Gemini context, there is only one Gemini floaty instance and this command dispatch call gets sent to `GeminiBrowserAgent` (which is browser/window bound). So if there's other scenes, even if they remain active and this function is called, the Gemini floaty being invoked would be taken into account on the browser level and would likely early return if the floaty wasn't invoked in that window. If the floaty **was** invoked in that background scene and somehow passed the `UISceneActivationStateForegroundActive` check, then I suppose the Gemini floaty would show.

      In any case, if we early return in this function, the worst case scenario is that the floaty doesn't reappear when expected, and on the next scroll event (not in this CL), the floaty will reappear for the user.

      Scott Yoder
      `dismissViewControllerAnimated:` gets called in two places:
      1. when a modal view is dismissed, generally in response to a user action of some sort. This is probably most likely to happen while the scene is in the foreground because the user wouldn't be interacting with a background scene. (Please correct me if I'm wrong about this).
      2. When the scene is disconnected

      I think Floaty only needs the opportunity to reappear in scenario 1 above.
      Joemer Ramos

      Yes that is all correct

      Gauthier Ambard

      There are cases where we dismiss the presented view controller of background scenes (actually it was the case of floaty).
      If you are ok with floaty not reappearing in those cases, I am good with it!
      You could also try locally and check what is the status of the windowScene at this point, maybe there is a specific state.

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Joemer Ramos
      • Scott Yoder
      Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement satisfiedCode-Owners
      • requirement satisfiedCode-Review
      • requirement is not satisfiedNo-Unresolved-Comments
      • requirement satisfiedReview-Enforcement
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: chromium/src
      Gerrit-Branch: main
      Gerrit-Change-Id: Ic7554e6e14bb5e265d2cabf3c8a18d4af58497b3
      Gerrit-Change-Number: 7669564
      Gerrit-PatchSet: 14
      Gerrit-Owner: Joemer Ramos <joeme...@google.com>
      Gerrit-Reviewer: Adam Arcaro <ada...@google.com>
      Gerrit-Reviewer: Gauthier Ambard <gam...@chromium.org>
      Gerrit-Reviewer: Joemer Ramos <joeme...@google.com>
      Gerrit-Reviewer: Scott Yoder <scott...@google.com>
      Gerrit-Attention: Joemer Ramos <joeme...@google.com>
      Gerrit-Attention: Scott Yoder <scott...@google.com>
      Gerrit-Comment-Date: Mon, 23 Mar 2026 14:11:48 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: Yes
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Joemer Ramos (Gerrit)

      unread,
      10:15 AM (8 hours ago) 10:15 AM
      to Joemer Ramos, Scott Yoder, Gauthier Ambard, Adam Arcaro, Chromium LUCI CQ, chromium...@chromium.org, ios-revie...@chromium.org, ios-r...@chromium.org, marq+...@chromium.org
      Attention needed from Scott Yoder

      Joemer Ramos added 1 comment

      Patchset-level comments
      File-level comment, Patchset 14 (Latest):
      Joemer Ramos . unresolved

      Leaving as unresolved for me: tests are failing because command dispatcher is not available at `[SceneCoordinator start]` so creating a view controller delegate and adding checks to not call the dispatcher until the CommandDispatcher is ready.

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Scott Yoder
      Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement satisfiedCode-Owners
      • requirement satisfiedCode-Review
      • requirement is not satisfiedNo-Unresolved-Comments
      • requirement satisfiedReview-Enforcement
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: chromium/src
      Gerrit-Branch: main
      Gerrit-Change-Id: Ic7554e6e14bb5e265d2cabf3c8a18d4af58497b3
      Gerrit-Change-Number: 7669564
      Gerrit-PatchSet: 14
      Gerrit-Owner: Joemer Ramos <joeme...@google.com>
      Gerrit-Reviewer: Adam Arcaro <ada...@google.com>
      Gerrit-Reviewer: Gauthier Ambard <gam...@chromium.org>
      Gerrit-Reviewer: Joemer Ramos <joeme...@google.com>
      Gerrit-Reviewer: Scott Yoder <scott...@google.com>
      Gerrit-Attention: Scott Yoder <scott...@google.com>
      Gerrit-Comment-Date: Mon, 23 Mar 2026 14:15:30 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Joemer Ramos (Gerrit)

      unread,
      10:45 AM (7 hours ago) 10:45 AM
      to Joemer Ramos, Scott Yoder, Gauthier Ambard, Adam Arcaro, Chromium LUCI CQ, chromium...@chromium.org, ios-revie...@chromium.org, ios-r...@chromium.org, marq+...@chromium.org
      Attention needed from Gauthier Ambard and Scott Yoder

      Joemer Ramos added 3 comments

      Patchset-level comments
      File-level comment, Patchset 14:
      Joemer Ramos . resolved

      Leaving as unresolved for me: tests are failing because command dispatcher is not available at `[SceneCoordinator start]` so creating a view controller delegate and adding checks to not call the dispatcher until the CommandDispatcher is ready.

      Joemer Ramos

      Done

      File-level comment, Patchset 15 (Latest):
      Joemer Ramos . resolved

      Can i get a second pass? More checks for command dispatcher to not throw unrecognized selector

      File ios/chrome/browser/scene/ui/scene_view_controller.mm
      Line 243, Patchset 14: UISceneActivationStateForegroundActive) {
      Gauthier Ambard . resolved

      How does that work when the scene is in background? I don't have a clear flow in mind, but let's assume you are on iPad with several scenes. This is called on a background scene. Is it ok to early return?

      Joemer Ramos

      I'm not sure how `dismissViewControllerAnimated:completion:` can be called while a scene is in the background **and** foregroundActive. Maybe @scott...@google.com knows?

      But for Gemini context, there is only one Gemini floaty instance and this command dispatch call gets sent to `GeminiBrowserAgent` (which is browser/window bound). So if there's other scenes, even if they remain active and this function is called, the Gemini floaty being invoked would be taken into account on the browser level and would likely early return if the floaty wasn't invoked in that window. If the floaty **was** invoked in that background scene and somehow passed the `UISceneActivationStateForegroundActive` check, then I suppose the Gemini floaty would show.

      In any case, if we early return in this function, the worst case scenario is that the floaty doesn't reappear when expected, and on the next scroll event (not in this CL), the floaty will reappear for the user.

      Scott Yoder
      `dismissViewControllerAnimated:` gets called in two places:
      1. when a modal view is dismissed, generally in response to a user action of some sort. This is probably most likely to happen while the scene is in the foreground because the user wouldn't be interacting with a background scene. (Please correct me if I'm wrong about this).
      2. When the scene is disconnected

      I think Floaty only needs the opportunity to reappear in scenario 1 above.
      Joemer Ramos

      Yes that is all correct

      Gauthier Ambard

      There are cases where we dismiss the presented view controller of background scenes (actually it was the case of floaty).
      If you are ok with floaty not reappearing in those cases, I am good with it!
      You could also try locally and check what is the status of the windowScene at this point, maybe there is a specific state.

      Joemer Ramos

      Apologies, maybe I'm forgetting one of the user journies (10+) but I'm not aware of any case where the floaty needs to listen to a presented view controller dismissing when a scene is backgrounded.

      @scott...@google.com IIUC we only have one UIWindow and UIWindowScene for each instance of Chrome where we can have more if we have multiwindow on iPad. The only thing I could think of is dismissing a second iPad window. In that event, the floaty **would** be on the other window. If the floaty is in the dismissed window, then we don't care about the floaty UI update.

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Gauthier Ambard
      • Scott Yoder
      Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement is not satisfiedCode-Owners
      • requirement is not satisfiedCode-Review
      • requirement is not satisfiedReview-Enforcement
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: chromium/src
      Gerrit-Branch: main
      Gerrit-Change-Id: Ic7554e6e14bb5e265d2cabf3c8a18d4af58497b3
      Gerrit-Change-Number: 7669564
      Gerrit-PatchSet: 15
      Gerrit-Owner: Joemer Ramos <joeme...@google.com>
      Gerrit-Reviewer: Adam Arcaro <ada...@google.com>
      Gerrit-Reviewer: Gauthier Ambard <gam...@chromium.org>
      Gerrit-Reviewer: Joemer Ramos <joeme...@google.com>
      Gerrit-Reviewer: Scott Yoder <scott...@google.com>
      Gerrit-Attention: Scott Yoder <scott...@google.com>
      Gerrit-Attention: Gauthier Ambard <gam...@chromium.org>
      Gerrit-Comment-Date: Mon, 23 Mar 2026 14:45:35 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Gauthier Ambard (Gerrit)

      unread,
      11:29 AM (6 hours ago) 11:29 AM
      to Joemer Ramos, Scott Yoder, Adam Arcaro, Chromium LUCI CQ, chromium...@chromium.org, ios-revie...@chromium.org, ios-r...@chromium.org, marq+...@chromium.org
      Attention needed from Joemer Ramos and Scott Yoder

      Gauthier Ambard voted Code-Review+1

      Code-Review+1
      Open in Gerrit

      Related details

      Attention is currently required from:
      • Joemer Ramos
      • Scott Yoder
      Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement satisfiedCode-Owners
      • requirement satisfiedCode-Review
      • requirement satisfiedReview-Enforcement
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: chromium/src
      Gerrit-Branch: main
      Gerrit-Change-Id: Ic7554e6e14bb5e265d2cabf3c8a18d4af58497b3
      Gerrit-Change-Number: 7669564
      Gerrit-PatchSet: 15
      Gerrit-Owner: Joemer Ramos <joeme...@google.com>
      Gerrit-Reviewer: Adam Arcaro <ada...@google.com>
      Gerrit-Reviewer: Gauthier Ambard <gam...@chromium.org>
      Gerrit-Reviewer: Joemer Ramos <joeme...@google.com>
      Gerrit-Reviewer: Scott Yoder <scott...@google.com>
      Gerrit-Attention: Joemer Ramos <joeme...@google.com>
      Gerrit-Attention: Scott Yoder <scott...@google.com>
      Gerrit-Comment-Date: Mon, 23 Mar 2026 15:28:43 +0000
      Gerrit-HasComments: No
      Gerrit-Has-Labels: Yes
      satisfied_requirement
      open
      diffy

      Gauthier Ambard (Gerrit)

      unread,
      11:32 AM (6 hours ago) 11:32 AM
      to Joemer Ramos, Scott Yoder, Adam Arcaro, Chromium LUCI CQ, chromium...@chromium.org, ios-revie...@chromium.org, ios-r...@chromium.org, marq+...@chromium.org
      Attention needed from Joemer Ramos and Scott Yoder

      Gauthier Ambard added 1 comment

      File ios/chrome/browser/scene/ui/scene_view_controller.mm
      Line 243, Patchset 14: UISceneActivationStateForegroundActive) {
      Gauthier Ambard . unresolved

      How does that work when the scene is in background? I don't have a clear flow in mind, but let's assume you are on iPad with several scenes. This is called on a background scene. Is it ok to early return?

      Joemer Ramos

      I'm not sure how `dismissViewControllerAnimated:completion:` can be called while a scene is in the background **and** foregroundActive. Maybe @scott...@google.com knows?

      But for Gemini context, there is only one Gemini floaty instance and this command dispatch call gets sent to `GeminiBrowserAgent` (which is browser/window bound). So if there's other scenes, even if they remain active and this function is called, the Gemini floaty being invoked would be taken into account on the browser level and would likely early return if the floaty wasn't invoked in that window. If the floaty **was** invoked in that background scene and somehow passed the `UISceneActivationStateForegroundActive` check, then I suppose the Gemini floaty would show.

      In any case, if we early return in this function, the worst case scenario is that the floaty doesn't reappear when expected, and on the next scroll event (not in this CL), the floaty will reappear for the user.

      Scott Yoder
      `dismissViewControllerAnimated:` gets called in two places:
      1. when a modal view is dismissed, generally in response to a user action of some sort. This is probably most likely to happen while the scene is in the foreground because the user wouldn't be interacting with a background scene. (Please correct me if I'm wrong about this).
      2. When the scene is disconnected

      I think Floaty only needs the opportunity to reappear in scenario 1 above.
      Joemer Ramos

      Yes that is all correct

      Gauthier Ambard

      There are cases where we dismiss the presented view controller of background scenes (actually it was the case of floaty).
      If you are ok with floaty not reappearing in those cases, I am good with it!
      You could also try locally and check what is the status of the windowScene at this point, maybe there is a specific state.

      Joemer Ramos

      Apologies, maybe I'm forgetting one of the user journies (10+) but I'm not aware of any case where the floaty needs to listen to a presented view controller dismissing when a scene is backgrounded.

      @scott...@google.com IIUC we only have one UIWindow and UIWindowScene for each instance of Chrome where we can have more if we have multiwindow on iPad. The only thing I could think of is dismissing a second iPad window. In that event, the floaty **would** be on the other window. If the floaty is in the dismissed window, then we don't care about the floaty UI update.

      Gauthier Ambard

      My example was:
      1. I open floaty on window A
      2. I background A
      3. I foreground window B and open floaty

      As floaty is (was?) a singleton, opening it in B dismisses it in A. I know here it doesn't really impact it as this is what we want, but technically a VC is dismissed on A while it is in background. I am sure there are several other occurrences with other VC, this is just the most recent one I reviewed.

      So, the question is: how bad it is if we never bring back floaty? If it is just that the user needs to re-invoke it, I am fine. If it is breaking things durably, it is not great.

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Joemer Ramos
      • Scott Yoder
      Submit Requirements:
        • requirement satisfiedCode-Coverage
        • requirement satisfiedCode-Owners
        • requirement satisfiedCode-Review
        • requirement is not satisfiedNo-Unresolved-Comments
        • requirement satisfiedReview-Enforcement
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: comment
        Gerrit-Project: chromium/src
        Gerrit-Branch: main
        Gerrit-Change-Id: Ic7554e6e14bb5e265d2cabf3c8a18d4af58497b3
        Gerrit-Change-Number: 7669564
        Gerrit-PatchSet: 15
        Gerrit-Owner: Joemer Ramos <joeme...@google.com>
        Gerrit-Reviewer: Adam Arcaro <ada...@google.com>
        Gerrit-Reviewer: Gauthier Ambard <gam...@chromium.org>
        Gerrit-Reviewer: Joemer Ramos <joeme...@google.com>
        Gerrit-Reviewer: Scott Yoder <scott...@google.com>
        Gerrit-Attention: Joemer Ramos <joeme...@google.com>
        Gerrit-Attention: Scott Yoder <scott...@google.com>
        Gerrit-Comment-Date: Mon, 23 Mar 2026 15:32:06 +0000
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Joemer Ramos (Gerrit)

        unread,
        12:01 PM (6 hours ago) 12:01 PM
        to Joemer Ramos, Gauthier Ambard, Scott Yoder, Adam Arcaro, Chromium LUCI CQ, chromium...@chromium.org, ios-revie...@chromium.org, ios-r...@chromium.org, marq+...@chromium.org
        Attention needed from Scott Yoder

        Joemer Ramos added 1 comment

        File ios/chrome/browser/scene/ui/scene_view_controller.mm
        Line 243, Patchset 14: UISceneActivationStateForegroundActive) {
        Gauthier Ambard . resolved
        Joemer Ramos

        Ahh ok thanks for explaining Gauthier! In that case, it's not bad at all that we never bring back the floaty since it's a singleton. The user would just need to re-invoke it and this is an expected user experience!

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Scott Yoder
        Submit Requirements:
          • requirement satisfiedCode-Coverage
          • requirement satisfiedCode-Owners
          • requirement satisfiedCode-Review
          • requirement satisfiedReview-Enforcement
          Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
          Gerrit-MessageType: comment
          Gerrit-Project: chromium/src
          Gerrit-Branch: main
          Gerrit-Change-Id: Ic7554e6e14bb5e265d2cabf3c8a18d4af58497b3
          Gerrit-Change-Number: 7669564
          Gerrit-PatchSet: 15
          Gerrit-Owner: Joemer Ramos <joeme...@google.com>
          Gerrit-Reviewer: Adam Arcaro <ada...@google.com>
          Gerrit-Reviewer: Gauthier Ambard <gam...@chromium.org>
          Gerrit-Reviewer: Joemer Ramos <joeme...@google.com>
          Gerrit-Reviewer: Scott Yoder <scott...@google.com>
          Gerrit-Attention: Scott Yoder <scott...@google.com>
          Gerrit-Comment-Date: Mon, 23 Mar 2026 16:01:05 +0000
          satisfied_requirement
          open
          diffy

          Scott Yoder (Gerrit)

          unread,
          12:06 PM (6 hours ago) 12:06 PM
          to Joemer Ramos, Gauthier Ambard, Adam Arcaro, Chromium LUCI CQ, chromium...@chromium.org, ios-revie...@chromium.org, ios-r...@chromium.org, marq+...@chromium.org
          Attention needed from Joemer Ramos

          Scott Yoder voted and added 1 comment

          Votes added by Scott Yoder

          Code-Review+1

          1 comment

          Patchset-level comments
          Scott Yoder . resolved

          LGTM

          Open in Gerrit

          Related details

          Attention is currently required from:
          • Joemer Ramos
          Submit Requirements:
          • requirement satisfiedCode-Coverage
          • requirement satisfiedCode-Owners
          • requirement satisfiedCode-Review
          • requirement satisfiedReview-Enforcement
          Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
          Gerrit-MessageType: comment
          Gerrit-Project: chromium/src
          Gerrit-Branch: main
          Gerrit-Change-Id: Ic7554e6e14bb5e265d2cabf3c8a18d4af58497b3
          Gerrit-Change-Number: 7669564
          Gerrit-PatchSet: 15
          Gerrit-Owner: Joemer Ramos <joeme...@google.com>
          Gerrit-Reviewer: Adam Arcaro <ada...@google.com>
          Gerrit-Reviewer: Gauthier Ambard <gam...@chromium.org>
          Gerrit-Reviewer: Joemer Ramos <joeme...@google.com>
          Gerrit-Reviewer: Scott Yoder <scott...@google.com>
          Gerrit-Attention: Joemer Ramos <joeme...@google.com>
          Gerrit-Comment-Date: Mon, 23 Mar 2026 16:06:39 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: Yes
          satisfied_requirement
          open
          diffy

          Joemer Ramos (Gerrit)

          unread,
          12:09 PM (6 hours ago) 12:09 PM
          to Joemer Ramos, Scott Yoder, Gauthier Ambard, Adam Arcaro, Chromium LUCI CQ, chromium...@chromium.org, ios-revie...@chromium.org, ios-r...@chromium.org, marq+...@chromium.org

          Joemer Ramos voted and added 1 comment

          Votes added by Joemer Ramos

          Commit-Queue+2

          1 comment

          Patchset-level comments
          Joemer Ramos . resolved

          Thank you both!

          Open in Gerrit

          Related details

          Attention set is empty
          Submit Requirements:
          • requirement satisfiedCode-Coverage
          • requirement satisfiedCode-Owners
          • requirement satisfiedCode-Review
          • requirement satisfiedReview-Enforcement
          Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
          Gerrit-MessageType: comment
          Gerrit-Project: chromium/src
          Gerrit-Branch: main
          Gerrit-Change-Id: Ic7554e6e14bb5e265d2cabf3c8a18d4af58497b3
          Gerrit-Change-Number: 7669564
          Gerrit-PatchSet: 15
          Gerrit-Owner: Joemer Ramos <joeme...@google.com>
          Gerrit-Reviewer: Adam Arcaro <ada...@google.com>
          Gerrit-Reviewer: Gauthier Ambard <gam...@chromium.org>
          Gerrit-Reviewer: Joemer Ramos <joeme...@google.com>
          Gerrit-Reviewer: Scott Yoder <scott...@google.com>
          Gerrit-Comment-Date: Mon, 23 Mar 2026 16:09:14 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: Yes
          satisfied_requirement
          open
          diffy

          Chromium LUCI CQ (Gerrit)

          unread,
          12:13 PM (6 hours ago) 12:13 PM
          to Joemer Ramos, Scott Yoder, Gauthier Ambard, Adam Arcaro, chromium...@chromium.org, ios-revie...@chromium.org, ios-r...@chromium.org, marq+...@chromium.org

          Chromium LUCI CQ submitted the change

          Change information

          Commit message:
          [iOS] Safety Checks To Avoid Gemini Calls After SceneDidDisconnect

          The TabGridViewController's `dismissViewControllerAnimated:completion:`
          is called in response to the scene being disconnected. Therefore, we
          should check if the scene activation state shows that the app is still
          in an active foreground and not detached to avoid sending calls to
          `geminiHandler`.

          This change was also added in SceneViewController to ensure that this
          functionality works with flag `UseSceneViewController` enabled as
          TabGridViewController's `dismissViewControllerAnimated:completion:`
          isn't triggered when this feature is enabled since TabGridViewController
          is not the root view controller.

          I was also investigating mini crash dumps and noticed that
          `self.geminiHandler` was nil, so I also added a safety check to make
          sure we're not calling a value that's nil. Obj-C objects generally don't
          call the selector function if the object is nil, but perhaps this is
          failing because the object is technically a CommandDispatcher/C++ object
          and a zombie referencing is being called.

          I'm not too sure about scene lifecycles so leaning on gambard@ and
          scottyoder@ for some expertise if this would help avoid calling the
          gemini handler which is causing crashes.

          Note: This doesn't solve all the crashes in crbug.com/490834944 but it
          should solve most of them.
          Bug: 490834944
          Fixed: 493219724
          Change-Id: Ic7554e6e14bb5e265d2cabf3c8a18d4af58497b3
          Reviewed-by: Scott Yoder <scott...@google.com>
          Commit-Queue: Joemer Ramos <joeme...@google.com>
          Reviewed-by: Gauthier Ambard <gam...@chromium.org>
          Cr-Commit-Position: refs/heads/main@{#1603536}
          Files:
          • M ios/chrome/browser/scene/coordinator/BUILD.gn
          • M ios/chrome/browser/scene/coordinator/DEPS
          • M ios/chrome/browser/scene/coordinator/scene_coordinator.mm
          • M ios/chrome/browser/scene/ui/BUILD.gn
          • M ios/chrome/browser/scene/ui/scene_view_controller.h
          • M ios/chrome/browser/scene/ui/scene_view_controller.mm
          • A ios/chrome/browser/scene/ui/scene_view_controller_delegate.h
          • M ios/chrome/browser/tab_switcher/ui_bundled/tab_grid/tab_grid_view_controller.mm
          Change size: M
          Delta: 8 files changed, 82 insertions(+), 3 deletions(-)
          Branch: refs/heads/main
          Submit Requirements:
          • requirement satisfiedCode-Review: +1 by Gauthier Ambard, +1 by Scott Yoder
          Open in Gerrit
          Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
          Gerrit-MessageType: merged
          Gerrit-Project: chromium/src
          Gerrit-Branch: main
          Gerrit-Change-Id: Ic7554e6e14bb5e265d2cabf3c8a18d4af58497b3
          Gerrit-Change-Number: 7669564
          Gerrit-PatchSet: 16
          Gerrit-Owner: Joemer Ramos <joeme...@google.com>
          Gerrit-Reviewer: Adam Arcaro <ada...@google.com>
          Gerrit-Reviewer: Chromium LUCI CQ <chromiu...@luci-project-accounts.iam.gserviceaccount.com>
          Gerrit-Reviewer: Gauthier Ambard <gam...@chromium.org>
          Gerrit-Reviewer: Joemer Ramos <joeme...@google.com>
          Gerrit-Reviewer: Scott Yoder <scott...@google.com>
          open
          diffy
          satisfied_requirement
          Reply all
          Reply to author
          Forward
          0 new messages