Skip to content

Conversation

@catalinradoiu
Copy link
Contributor

@catalinradoiu catalinradoiu commented Dec 5, 2025

Task/Issue URL: https://app.asana.com/1/137249556945/project/1211724162604201/task/1212317263326283?focus=true

Description

This PR improves the handling of new tabs with empty URLs by:

  1. Delaying the handleNewTabIfEmptyUrl() call with a 200ms delay to ensure proper timing
  2. Moving the handleNewTabIfEmptyUrl() call from onMessageReceived() to be triggered after a delay
  3. Changing the empty URL detection logic to check if webNavigationState == null instead of checking site?.url.isNullOrEmpty()
  4. Making handleNewTabIfEmptyUrl() public to support the new calling pattern

The delay is necessary because we need to wait for other webview events to be fired, before setting the about blank text in the omnibar. If there are other events fired and the navigation state changed, then it means that a new url is about to be loaded. In case the navigation state does’t change we are in the spoofing scenario.

Steps to test this PR

Steps to test this PR

Handle about:blank in omnibar

UI changes

Before After
glitch_before_fix.mp4 (uploaded via Graphite) after_fix_no_ui_glitch.mp4 (uploaded via Graphite)

Note

Delays about:blank handling by 200ms after new window messages, switches empty-tab detection to navigation-state based, exposes the handler, and updates tests to match.

  • BrowserTabViewModel:
    • Make handleNewTabIfEmptyUrl() public and change condition to webNavigationState == null (instead of site?.url.isNullOrEmpty()).
    • Remove immediate call from onMessageReceived().
  • BrowserTabFragment:
    • In processMessage, add a 200ms delayed call to viewModel.handleNewTabIfEmptyUrl() (CHECK_IF_ABOUT_BLANK_DELAY).
  • Tests (BrowserTabViewModelTest):
    • Rename and update tests to call handleNewTabIfEmptyUrl() directly and validate new navigation-state logic (including Custom Tab scenarios).
  • Misc:
    • Add distinctUntilChanged import and define CHECK_IF_ABOUT_BLANK_DELAY constant.

Written by Cursor Bugbot for commit fc4556d. This will update automatically on new commits. Configure here.

Previously, about:blank was shown immediately in onMessageReceived(), causing visible flicker in legitimate navigations when the real URL loaded shortly after.

Now defer the about:blank check to allow WebView callbacks to fire. If callbacks fire (legitimate case), omnibar shows the real URL. If no callbacks fire (spoofing case), show about:blank.
Copy link
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@catalinradoiu catalinradoiu changed the title Fix URL spoofing flicker in onCreateWindow tabs Fix URL flicker in onCreateWindow tabs Dec 5, 2025
@catalinradoiu catalinradoiu changed the title Fix URL flicker in onCreateWindow tabs Fix "about:blank" flicker in onCreateWindow tabs Dec 5, 2025
@catalinradoiu catalinradoiu changed the title Fix "about:blank" flicker in onCreateWindow tabs Fix "about:blank" flicker in omnibar when a link is opened in a new tab Dec 8, 2025
@catalinradoiu catalinradoiu marked this pull request as ready for review December 8, 2025 14:22
Copy link
Contributor

@anikiki anikiki left a comment

Choose a reason for hiding this comment

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

Looks good and works as expected! 🎉

@catalinradoiu catalinradoiu merged commit 1baf7af into develop Dec 8, 2025
13 checks passed
@catalinradoiu catalinradoiu deleted the fix/cradoiu/about-blank-glitch-fix branch December 8, 2025 19:48
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