Skip to content

Should share() be allowed to resolve immediately? #188

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

Closed
saschanaz opened this issue Oct 3, 2020 · 16 comments · Fixed by #209
Closed

Should share() be allowed to resolve immediately? #188

saschanaz opened this issue Oct 3, 2020 · 16 comments · Fixed by #209

Comments

@saschanaz
Copy link
Member

saschanaz commented Oct 3, 2020

Windows currently does not support a way to track share action consistently: https://bugzilla.mozilla.org/show_bug.cgi?id=1641280

Currently a caveat is that there is still no way to track selection of "Copy Link" feature, and doing so currently creates a promise that will never be resolved.

Edge team somehow decided to immediate resolve the promise regardless of what actually happens with the share data on Windows (at least since Edge 85) and never throw when canceled, but the spec says resolving should happen only after successful transmission:

Once the data has been successfully transmitted to the target, resolve [[sharePromise]] with undefined.

Should we revise the spec to allow Edge behavior?

@saschanaz saschanaz changed the title Is immediately resolving share() behavior an acceptable behavior? Should share() be allowed to resolve immediately? Oct 3, 2020
@marcoscaceres
Copy link
Member

That behavior doesn't sound great, tbh. Developers would get zero feedback. We should see if the Windows folks are willing to fix their API.

@saschanaz
Copy link
Member Author

saschanaz commented Oct 5, 2020

So far Twitter and YouTube are not using the result of the promise, that's probably why Edge team went that way. I'll try ping some relevant person at Microsoft.

@ewilligers
Copy link
Collaborator

The spec could gain a disclaimer paragraph, for platforms where it is not possible to distinguish cases 11.3, 11.5 and 11.6.

I don't see a reason to hold off shipping browser best-efforts.

@marcoscaceres
Copy link
Member

We've been successful encouraging OS API teams to make changes in the past (e.g., with the aforementioned dismissal callback on Windows). I think it would be worthwhile letting the Windows folks there is an issue.

@saschanaz, have you reached out to them?

@marcoscaceres
Copy link
Member

@saschanaz, I see you followed up with the windows folks in the Chrome bug. Thanks for doing that.

@saschanaz
Copy link
Member Author

saschanaz commented Oct 6, 2020

The spec could gain a disclaimer paragraph, for platforms where it is not possible to distinguish cases 11.3, 11.5 and 11.6.

Only when we get a way to feature detect, I guess. I think any undetectable behavior differences are a mess 🤔

Edit: Random idea, but could we return undefined instead of Promise<undefined> when user action can't be tracked? Theoretically it's not a compatible change, but if websites are not affected by Edge behavior I think it means they are not really using the return value. Feature detecting via return type also should make fingerprinting harder in this case.

@mhochk
Copy link

mhochk commented Oct 8, 2020

Small clarification on the claim that the Edge implementation immediately resolves - it does wait till the data has been successfully handed off to the OS and reports back based on that. It's still not a spec match, but is worth distinguishing from "immediate" in that it is async, does sometimes fail or get cancelled, and is providing slightly more information to the calling site than if it were to not return a Promise at all.

Regarding a way to feature detect this I agree that detecting via return type may be the best way, though think it would be more appropriate as a return value passed to the Promise. I'm anticipating possible implementations based on the latest available Windows APIs that would be able to usually report success or failure, but sometimes won't know for certain what happened and I would expect those scenarios to report this same indeterminate result.

@marcoscaceres
Copy link
Member

I think it's reasonable to assume that a best effort was made to hand a share off to the OS, and that hopefully the OS was able to give back the correct signals to the browser to indicate success/failure/abort... and where the OS can't give those assurances, resolve the promise. However, I think that should be implementation specific, because it may be that the Windows API ends up evolving over the next few years (i.e., we shouldn't work around current OS limitations in the spec - but we could note the reality of the situation in a note within the spec).

@saschanaz
Copy link
Member Author

saschanaz commented Oct 8, 2020

we shouldn't work around current OS limitations in the spec

I think we should do, as we can't really expect every OS provides same equivalent feature. Today it's Windows, but tomorrow it can be Ubuntu, KaiOS, or whatever new OS.

And especially when the old Windows builds won't die soon enough.

Edit: Did some chat, leaning to just allowing it for now and then seeing what really happens in real world. If it really turns out to be a problem we could add a return value, something like Response from fetch().

@marcoscaceres
Copy link
Member

I concur that it's mostly wishful thinking on my part - and in practice, this might be ok as on most OSs share dialogs are non-blocking modal dialogs. So, I'd be ok with a "SHOULD" on this.

moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this issue Aug 4, 2021
…ction on Windows r=smaug,agashlin

Windows does not fire any DataPackage event when a user selects copy action from the OS dialog, potentially causing never-resolved promise. Windows still does not provide any other way to detect that action, even on Windows 11.

Per w3c/web-share#188 Chromium gave up and decided not to wait for user action.

Given that Microsoft is not expected to fix the situation anytime soon, it's probably better to follow what others do.

Depends on D121420

tmp

Differential Revision: https://phabricator.services.mozilla.com/D121421
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this issue Aug 4, 2021
…ction on Windows r=smaug,agashlin

Windows does not fire any DataPackage event when a user selects copy action from the OS dialog, potentially causing never-resolved promise. Windows still does not provide any other way to detect that action, even on Windows 11.

Per w3c/web-share#188 Chromium gave up and decided not to wait for user action.

Given that Microsoft is not expected to fix the situation anytime soon, it's probably better to follow what others do.

Depends on D121420

tmp

Differential Revision: https://phabricator.services.mozilla.com/D121421
jamienicol pushed a commit to jamienicol/gecko that referenced this issue Aug 6, 2021
…ction on Windows r=smaug,agashlin

Windows does not fire any DataPackage event when a user selects copy action from the OS dialog, potentially causing never-resolved promise. Windows still does not provide any other way to detect that action, even on Windows 11.

Per w3c/web-share#188 Chromium gave up and decided not to wait for user action.

Given that Microsoft is not expected to fix the situation anytime soon, it's probably better to follow what others do.

Depends on D121420

tmp

Differential Revision: https://phabricator.services.mozilla.com/D121421
jamienicol pushed a commit to jamienicol/gecko that referenced this issue Aug 6, 2021
…ction on Windows r=smaug,agashlin

Windows does not fire any DataPackage event when a user selects copy action from the OS dialog, potentially causing never-resolved promise. Windows still does not provide any other way to detect that action, even on Windows 11.

Per w3c/web-share#188 Chromium gave up and decided not to wait for user action.

Given that Microsoft is not expected to fix the situation anytime soon, it's probably better to follow what others do.

Depends on D121420

tmp

Differential Revision: https://phabricator.services.mozilla.com/D121421
@saschanaz
Copy link
Member Author

Note that Mozilla is now following what Chromium does: https://phabricator.services.mozilla.com/D121421

@marcoscaceres
Copy link
Member

@saschanaz, sorry, it's been a while... do we need to update the spec or are we ok?

@saschanaz
Copy link
Member Author

The spec should be revised to describe real browser behavior.

@marcoscaceres
Copy link
Member

Happy to update, but could use some help.

The spec says (step 11.6):

Once the data has been successfully transmitted to the target, resolve [[sharePromise]] with undefined.

Isn't that what reflecting the browser behavior right now? I.e., we don't wait for confirmation or cancellation.

That seems to also align with the Gecko patch, in as far as that there is OS handoff of the data and that's as much as we can expect?

@saschanaz
Copy link
Member Author

"the target" is the share target (this should be linked), not the OS, and it's the behavior on mobile devices. It should be loosened, something like:

Once the data has been successfully transmitted to the share target, or to the OS if the transmission to the share target cannot be detected, resolve [[sharePromise]] with undefined.

@marcoscaceres
Copy link
Member

Thanks @saschanaz! the explanation helped a lot. I send #209 with some small clarifications. Let me know what you think!

saschanaz added a commit to saschanaz/winrt-api that referenced this issue Jan 29, 2023
I tried to ping some Microsoft people to fix this, but as of Windows 11 22623.1245 this is still the behavior.

Some history:
* w3c/web-share#188
* https://bugs.chromium.org/p/chromium/issues/detail?id=1107660
* https://phabricator.services.mozilla.com/D121421

You can check this behavior on Firefox by enabling `widget.windows.share.wait_action.enabled` and select "Copy link" in the share dialog from https://web-share.glitch.me.
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 a pull request may close this issue.

4 participants