Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[url_launcher][web] Prevent browser from navigating when followLink isn't called #8675

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mdebbar
Copy link
Contributor

@mdebbar mdebbar commented Feb 21, 2025

When a DOM click event is received, we need to make a decision before the end of the event loop whether to allow the browser to navigate or not. At the end of the event loop, the browser will perform the navigation if we don't prevent it.

The problem occurs when the followLink signal arrives AFTER the event loop (this can happen in semantics mode when the web engine uses a debouncer to queue events and send them to the framework after some delay). This leads to a situation where we can't make a definitive decision by the end of the event loop, so this PR does the following:

  1. [best case] If the followLink signal is received before the end of the event loop, we let the browser do the navigation for a full web link experience.

  2. [meh case] If no followLink signal is received before the end of the event loop, we PREVENT the browser from navigating. But we keep waiting for the followLink signal. If the signal arrives a bit later, we fallback to a programmatic navigation through the launchUrl API.

Fixes flutter/flutter#162927
Fixes flutter/flutter#162408

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant