Bug 231995

Summary: Webshare API Level 2 "Save Image" not resolving the navigator in IOS 15
Product: WebKit Reporter: John <janeDoe87583784>
Component: New BugsAssignee: Tim Horton <thorton>
Status: RESOLVED FIXED    
Severity: Major CC: adin, akeerthi, bdakin, deimantas, evancarlson, hi, jeansson.andreas, marcosc, marcos, olle, perrariccardo0, sabouhallawa, spreadpando, thorton, tomac, tony, tri, webkit-bug-importer, westbrook.johnson
Priority: P2 Keywords: InRadar
Version: Safari 15   
Hardware: iPhone / iPad   
OS: Other   
See Also: https://bugs.webkit.org/show_bug.cgi?id=244408
Attachments:
Description Flags
The share buttons become blocked after clicking "Save Image" and it does not fail or succeed none

Description John 2021-10-19 17:17:57 PDT
Created attachment 441821 [details]
The share buttons become blocked after clicking "Save Image" and it does not fail or succeed

The new update to IOS 15 has brought the default usability of the Webshare API Level 2 but I have found bug whilst implementing it. 

I have been attempting to implement the file sharing into my own application specifically with image files. 
When testing on an iPhone using IOS15, when you attempt to share an image from Safari using the Webshare API, if you select the "Save Image" option (saves image to photos application), the navigator closes but does not resolve.

This means that if you attempt to activate the navigator again in any way, it is no longer available in the same context and throws an exception - you have to refresh the page to reset the unresolved navigator. 

This can be replicated on the demo page using Safari IOS 15 by attempting to share an image and clicking the "Save Image" button - you will see the buttons remain disabled:
https://w3c.github.io/web-share/demos/share-files.htm

I hope this was the right place to post this bug. It is awesome to have the Webshare API Level 2 integration progressing forwards, this is just a frustrating bug that is hindering the usability of it in the new IOS 15.
Comment 1 Tim Horton 2021-10-20 10:08:22 PDT
(In reply to John from comment #0)
> Created attachment 441821 [details]
> I hope this was the right place to post this bug. It is awesome to have the
> Webshare API Level 2 integration progressing forwards, this is just a
> frustrating bug that is hindering the usability of it in the new IOS 15.

This is totally the right place! Thank you for the report, this is news to me.
Comment 2 Radar WebKit Bug Importer 2021-10-20 10:09:00 PDT
<rdar://problem/84467461>
Comment 3 Marcos Caceres 2021-10-21 04:55:57 PDT
Correct link: https://w3c.github.io/web-share/demos/share-files.html … also confirmed, the promise doesn’t seem to be resolving or something.
Comment 4 John 2021-10-21 16:23:24 PDT
Sorry, I didn't realise I had accidentally dropped the "l" on the end of the url! Thanks for catching that :)
Comment 5 Tim Horton 2021-12-13 12:37:22 PST
*** Bug 234187 has been marked as a duplicate of this bug. ***
Comment 6 ag_ac 2022-03-14 12:22:06 PDT
We also were able to reproduce this issue on iOS15.3.1

Saving an image from within the share sheet blocks the user from being able to subsequently share the image via another app.

This issue is present on multiple live web apps that we have built, and we have received several bug reports from users, sharing that they are unable to share the image after saving it.
Comment 7 Tim Horton 2022-04-03 14:04:58 PDT
*** Bug 238713 has been marked as a duplicate of this bug. ***
Comment 8 Olle Soprani 2022-06-15 03:54:16 PDT
This bug is still present in iOS 15.5 and is becoming more and more annoying. The development of social sharing is expanding enormously, and this feature is the most reported, by our users.

Are there nobody who wants to address this. Is there any status of this issue?

Best Regards 
Olle
Comment 9 Marcos Caceres 2022-08-28 18:34:35 PDT
*** Bug 244408 has been marked as a duplicate of this bug. ***
Comment 10 Tim Horton 2022-09-09 17:14:39 PDT
The bug here is that the check here:

```
// Make sure that we're actually not presented anymore (-completionWithItemsHandler can be called multiple times
// before the share sheet is actually dismissed), and if so, clean up.
if (![_shareSheetViewController presentingViewController])
    [self dismiss];
```

which was introduced in https://commits.webkit.org/229913@main (by me!) is failing, but only in the Save Image case. We must be getting the callback before the share sheet is dismissed, and never get another.

I'll have to page back in all of the details of https://commits.webkit.org/229913@main and see if we can fix it a different way...
Comment 11 Tim Horton 2022-09-09 17:46:08 PDT
Pull request: https://github.com/WebKit/WebKit/pull/4209
Comment 12 EWS 2022-09-09 19:55:50 PDT
Committed 254346@main (eda885f3f281): <https://commits.webkit.org/254346@main>

Reviewed commits have been landed. Closing PR #4209 and removing active labels.
Comment 13 Tim Horton 2022-09-30 18:12:01 PDT
*** Bug 245854 has been marked as a duplicate of this bug. ***
Comment 14 Thomas Steiner 2022-10-03 03:28:55 PDT
*** Bug 245958 has been marked as a duplicate of this bug. ***
Comment 15 Thomas Steiner 2022-10-03 03:29:15 PDT
Since bugs get duplicated against this bug (https://bugs.webkit.org/show_bug.cgi?id=245958, https://bugs.webkit.org/show_bug.cgi?id=245854), please do not mark it as RESOLVED FIXED.
Comment 16 Tim Horton 2022-10-03 07:58:17 PDT
(In reply to Thomas Steiner from comment #15)
> Since bugs get duplicated against this bug
> (https://bugs.webkit.org/show_bug.cgi?id=245958,
> https://bugs.webkit.org/show_bug.cgi?id=245854), please do not mark it as
> RESOLVED FIXED.

Say what? That’s how we use bugzilla. RESOLVED FIXED tracks WebKit trunk, not any particular vendor release. This fix isn’t in an iOS build yet, thus the dupes.
Comment 17 Alexey Proskuryakov 2023-02-13 09:59:47 PST
*** Bug 252132 has been marked as a duplicate of this bug. ***
Comment 18 evancarlson 2023-04-17 11:51:05 PDT
I have noticed that the Save Image button is now missing in the latest versions of iOS (16.2+).

This can be reproduced on the official W3C demo using Safari IOS 16.2+: https://w3c.github.io/web-share/demos/share-files.html

Note that I don't have access to any devices with earlier versions, so this could potentially affect all versions of iOS 16.

Can you kindly provide more information on whether this is an expected behavior or if there are any further updates on this issue?
Comment 19 Marcos Caceres 2023-04-17 21:16:14 PDT
(In reply to evancarlson from comment #18)
> I have noticed that the Save Image button is now missing in the latest
> versions of iOS (16.2+).

Yeah, the OS share-sheet may have changed in the last version of iOS. Saving the image (which implies downloading) is different from *sharing* an image.   
 
> This can be reproduced on the official W3C demo using Safari IOS 16.2+:
> https://w3c.github.io/web-share/demos/share-files.html
> 
> Note that I don't have access to any devices with earlier versions, so this
> could potentially affect all versions of iOS 16.
> 
> Can you kindly provide more information on whether this is an expected
> behavior or if there are any further updates on this issue?

I think it may be expected (but I will confirm internally). For example, if tap and hold on an image, you can "Save to photos". Again, the semantics of sharing and saving are slightly different.
Comment 20 evancarlson 2023-04-18 09:06:55 PDT
Hi Marcos,

Thanks for the prompt reply. Appreciate you confirming this internally!

If you tap and hold on an image, you can open a share sheet by pressing "Share", then you *do* see a "Save to photos" option. I wonder why the share sheets are different?

We would like a way to programmatically present users with a "Save to photos" option, instead of needing to implement UI prompting the user to tap + hold the photo.

This change is high impact for us. We have many customers with live commercial WebAR experiences reaching out, as this change adds friction to saving images.
Comment 21 ag_ac 2023-04-18 13:16:14 PDT
Our web agency manages dozens of interactive websites where photo sharing is a core part of the user experience.  This issue has caused substantial friction with our client base. We would like to avoid the confusing UX of asking users to tap-and-hold to Save to Photos, while showing a separate button to open the share tray to share a photo on other apps. We'd be very grateful if a fix were deployed for this issue soon. Thanks!
Comment 22 Marcos Caceres 2023-04-18 18:36:02 PDT
Hi Evan, Ag_ac, sorry I didn’t mean to imply you would use the tap and hold as the solution. That of course wouldn’t be a great experience for multiple photos. I was just noting that saving to photos is available in some contexts. 

Still looking if this a regression or not…

(In reply to evancarlson from comment #20)
> If you tap and hold on an image, you can open a share sheet by pressing
> "Share", then you *do* see a "Save to photos" option. I wonder why the share
> sheets are different?

Precisely… there is a mismatch there. 

> We would like a way to programmatically present users with a "Save to
> photos" option, instead of needing to implement UI prompting the user to tap
> + hold the photo.

I don’t think that will be possible. The API is not designed that way and I don’t think there is anything in HTML that would allow that.

> This change is high impact for us. We have many customers with live
> commercial WebAR experiences reaching out, as this change adds friction to
> saving images.

Understood. Appreciate you describing your use case and need.
Comment 23 Marcos Caceres 2023-04-18 21:24:30 PDT
Even, ag_ac, confirmed... filed and cc'ed you https://bugs.webkit.org/show_bug.cgi?id=255641
Comment 24 Marcos Caceres 2023-04-18 21:25:16 PDT
(In reply to Marcos Caceres from comment #23)
> Even, ag_ac, confirmed... filed and cc'ed you
> https://bugs.webkit.org/show_bug.cgi?id=255641

Sorry, I mean Evan!
Comment 25 Andreas 2023-04-20 01:11:24 PDT
I noticed this as well, just found a work around for the bug where the promise did not resolve when saving to camera roll and then when I updated iOS the option was now gone :(

I also noticed that now you do not get a thumbnail at the top of the share sheet anymore and the size of the file is also missing.

So now we are back at forcing the users to tap and hold to save, hope this will get resolved soon!