WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED CONFIGURATION CHANGED
215884
getUserMedia recurring permissions prompts in standalone when hash changes
https://bugs.webkit.org/show_bug.cgi?id=215884
Summary
getUserMedia recurring permissions prompts in standalone when hash changes
nfckngspmpls
Reported
2020-08-27 02:41:40 PDT
Context: I have a web app with a hash router. Once I am done analysing the camera stream and showing results my router changes the hash to a result route. When I come back to the camera view, I am prompted for the camera permissions again, even though I never left the web app. This behaviour does not happen in Safari for iOS. Current behaviour: In standalone mode, iOS is revoking the camera permissions every time the hash changes. Expected behaviour: In browser mode, once I am granted the camera use by the user, I can change the hash without loosing the camera permissions. Steps to reproduce: 1) Add a video tag to page 2) Ask for camera permissions and attach the stream to the video tag 3) Add a <a href="#"> to page 4) click on link In standalone mode: video stream is gone. In browser mode: video stream is still there. Current workaround: Set the Vue router to abstract mode.
Attachments
Per site setting iOS UI
(1.01 MB, image/jpeg)
2020-12-16 05:32 PST
,
youenn fablet
no flags
Details
View All
Add attachment
proposed patch, testcase, etc.
Radar WebKit Bug Importer
Comment 1
2020-08-29 11:39:39 PDT
<
rdar://problem/68001080
>
youenn fablet
Comment 2
2020-09-16 01:30:27 PDT
Thanks, I was able to repro with airhorner. It seems as if there is a navigation which stops all the capture tracks and reset the permissions when doing hash navigations in Web.app but not iOS Safari.
Alex Suzuki
Comment 3
2020-10-19 07:24:20 PDT
I have multiple PWAs which scan barcodes using and show the camera preview with getUserMedia. They use Angular routing. Everything works fine in Safari, but when added to home screen (PWA), the camera permission prompt will appear every time the route changes. Currently the only workaround we can offer to users is to provide blanket camera permissions (all web sites) in Safari. This is probably related to this issue.
Michal
Comment 4
2020-12-16 05:14:36 PST
(In reply to Alex Suzuki from
comment #3
)
> > Everything works fine in Safari, but when added to home screen (PWA), the > camera permission prompt will appear every time the route changes. > > This is probably related to this issue.
We have exactly this problem with our PWA which is based on QR scanner. It would be nice to have this working as in Safari.
Michal
Comment 5
2020-12-16 05:20:33 PST
(In reply to Alex Suzuki from
comment #3
)
> I have multiple PWAs which scan barcodes using and show the camera preview > with getUserMedia. They use Angular routing. > > Currently the only workaround we can offer to users is to provide blanket > camera permissions (all web sites) in Safari. >
Whad did you mean by this? Can you explain this workaround more please?
youenn fablet
Comment 6
2020-12-16 05:32:22 PST
(In reply to Michal from
comment #5
)
> (In reply to Alex Suzuki from
comment #3
) > > I have multiple PWAs which scan barcodes using and show the camera preview > > with getUserMedia. They use Angular routing. > > > > Currently the only workaround we can offer to users is to provide blanket > > camera permissions (all web sites) in Safari. > > > > Whad did you mean by this? Can you explain this workaround more please?
In iOS Safari, users can persistently grant camera/microphone access from Safari UI.
youenn fablet
Comment 7
2020-12-16 05:32:50 PST
Created
attachment 416332
[details]
Per site setting iOS UI
youenn fablet
Comment 8
2020-12-16 05:33:35 PST
I uploaded a screenshot that shows where to get per-site settings UI
Michal
Comment 9
2020-12-16 06:47:31 PST
(In reply to youenn fablet from
comment #8
)
> I uploaded a screenshot that shows where to get per-site settings UI
Yes I see, thank you for explanation of this. Of course this is working but there is need to do it manually by users. Which I don't want to delegate this problem to end-users. If you are calculating with thousands of them. Our problem is mainly with "Installed" PWA - "Add to Home screen" (in Safari), where this permission is not persisted after you did this install of the app.
youenn fablet
Comment 10
2020-12-16 07:06:33 PST
As a temporary workaround, I wonder whether the following would work: - Start capture - Before navigating inside the page, stop the capture by calling stream.getTracks().forEach(t => t.stop()) - Navigate within the same page - Restart capture (hopefully without a prompt this time).
youenn fablet
Comment 11
2021-01-05 04:49:39 PST
***
Bug 212040
has been marked as a duplicate of this bug. ***
youenn fablet
Comment 12
2021-01-05 04:52:48 PST
The fix is not in WebKit but in Safari standalone mode implementation. I'll keep this bug open until validation is done this works as expected.
Mauricio W
Comment 13
2021-01-11 21:04:29 PST
I don't think this issue is with Safari implementation. It also happens when running an app with WKWebView. Any changes to the path of the URL causes calls to `getUserMedia` to request permissions from the user again.
Mauricio W
Comment 14
2021-01-11 21:52:13 PST
It looks like the problem is a bit more serious in WKWebView. After allowing the prompt, any subsequent calls to `getUserMedia` after some period of time (looks to be about 90 seconds) will also trigger the prompt for permissions. This happens even without navigating away from the page, regardless of if the user was active or inactive in that time.
youenn fablet
Comment 15
2021-01-12 01:32:17 PST
(In reply to Mauricio W from
comment #14
)
> It looks like the problem is a bit more serious in WKWebView. > > After allowing the prompt, any subsequent calls to `getUserMedia` after some > period of time (looks to be about 90 seconds) will also trigger the prompt > for permissions. > > This happens even without navigating away from the page, regardless of if > the user was active or inactive in that time.
This is a different bug, which might best be fixed by exposing a delegate to control getUserMedia prompt. If capture is ongoing, prompt should not happen again until 24 hours. If capture is not ongoing, prompt should happen again after 1 minute of inactivity. This is the same behavior as Safari.
Mauricio W
Comment 16
2021-01-12 05:50:50 PST
Thanks for the reply, youenn. The documentation for this is rather scarce, so I wasn't sure. Thank you for clearing that up. I don't mean to sidetrack this thread, but since you brought it up: could you explain a bit more on how I could use a delegate to handle this? Reading through the WKWebview documentation there doesn't seem to be an obvious answer to me. I also spent some time trying to understand how the UserMediaRequest gets sent out, but I couldn't really understand the flow.
youenn fablet
Comment 17
2021-01-12 05:55:38 PST
(In reply to Mauricio W from
comment #16
)
> Thanks for the reply, youenn. The documentation for this is rather scarce, > so I wasn't sure. Thank you for clearing that up. > > I don't mean to sidetrack this thread, but since you brought it up: could > you explain a bit more on how I could use a delegate to handle this? Reading > through the WKWebview documentation there doesn't seem to be an obvious > answer to me. I also spent some time trying to understand how the > UserMediaRequest gets sent out, but I couldn't really understand the flow.
UserMediaRequest is sent through IPC to UIProcess. It is processed in UserMediaPermissionRequestManagerProxy which ultimately may call a WKWebView delegate dedicated to getUserMedia permission. This delegate is not yet exposed though.
Dan Strengier
Comment 18
2021-01-26 10:42:05 PST
I too have PWAs that use the camera to scan barcodes. It's proving very cumbersome for our users to confirm camera access every time they try and scan a QR code. The workaround to always allow camera access across all Safari websites is a *really bad workaround* because it completely breaks user's privacy controls, just so they can seamlessly scan barcodes using our app.
Bryce Wilson
Comment 19
2021-02-11 01:49:48 PST
I can also confirm this issue via a PWA install on home screen, the camera is requested on every page there is a camera instance initiated.
youenn fablet
Comment 20
2021-02-14 01:39:19 PST
Please check this in latest iOS 14.5 beta.
Matthias Rauch
Comment 21
2021-06-20 10:00:28 PDT
In 14.5 the prompt for camera permission does not show on every page anymore. That's an improvement, but the camera permission is not conserved over multiple session. That means the camera permission prompt still shows up, when the application is closed and reopend again. Are there any plans to resolve this behaviour too?
Charles S
Comment 22
2023-03-10 06:59:20 PST
This issue is still current with 16.3.1. User experience is miserable when multiple scans are performed more than 1 minute apart in standalone mode
bearman
Comment 23
2023-07-24 17:56:28 PDT
I wonder if some can provide some insight for me. Some claim this issue is resolved, others claim the issue persists. I've tested on MacOS 12.6.8 w/ Safari 16.6: Visit e.g. Google.com then `getUserMedia()` and `enumerateDevices` acts as expected. Attempting the same with (Swift's Webkit) only enumerate an empty input device and hangs when calling `getUserMedia`. Is this expected?
arkraft
Comment 24
2024-09-10 04:35:02 PDT
I have tried this on
https://whatpwacando.today/media/
and the problem still exists. I have tried it on my Mac and iPhone (16.6.1). On my iPhone the permission does not persist when disabling and enabling the camera or reloading the page. On Mac with Safari i get asked again after reloading the page. When using Chrome on Mac the permission is persisted after page reloads. We are developing a PWA with a camera function, so this is really something that is halting our development. It would be great if there would be a solution for this, thanks.
youenn fablet
Comment 25
2024-09-10 06:27:25 PDT
(In reply to arkraft from
comment #24
)
> I have tried this on
https://whatpwacando.today/media/
and the problem still > exists. I have tried it on my Mac and iPhone (16.6.1). > On my iPhone the permission does not persist when disabling and enabling the > camera or reloading the page. On Mac with Safari i get asked again after > reloading the page. When using Chrome on Mac the permission is persisted > after page reloads.
On Safari, there is the possibility to grant persistent access to camera and/or microphone.
> We are developing a PWA with a camera function, so this is really something > that is halting our development. It would be great if there would be a > solution for this, thanks.
Do you mean that you would like a way for a Home Screen web app to have persistent camera/microphone access? If so, could you file a new bug?
juaramos
Comment 26
2025-01-15 01:08:56 PST
Same problem here, any solution nowadays?
youenn fablet
Comment 27
2025-01-15 09:10:13 PST
The ask is not clear, can you clarify what the issue you would like to be solved?
juaramos
Comment 28
2025-01-20 08:29:06 PST
Is there any way to allow camera permissions one time? Problem: -Open app in browser mode -Open camera component and allow permission. -Open camera component again and it works. No permissions requested Then -Open app in browser mode -Open camera component and allow permission. -Install app as PWA -Open PWA, then open camera component again and the permissions is requested again. Other scenario -Open PWA on iPad -Open camera module and allow permissions -While the app is alive their permissions works fine (not asked each time) -If kill the app and cold start again the permissions are asked again.
robin.carduner
Comment 29
2025-06-25 08:04:18 PDT
I am experiencing this again on iOS 18.5. I visit our PWA website in Safari, set the camera permission to "Allow". Close the tab, close the browser, and visit the site again in Safari to confirm that the permission has persisted. Then I open the PWA via the previously installed shortcut. It asks for permission to use the camera again. I return to the website in Safari, and I see that the permission has reverted to "Ask". I don't remember this happening before upgrading to iOS 18.5, but it's also true that I haven't tested the app for a few weeks. Why, oh why, is it so difficult to get this right, after so many years? This (along with all the IndexedDB issues of course) is just killing us. Fortunately, this is an internal app -- we were previously locked into iOS because our app had been developed in Xamarin, but now we finally have the chance to migrate away from Apple products. That day can't come soon enough.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug