mediaDevices deviceId persists across browser instances

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

mediaDevices deviceId persists across browser instances

Postby turtle1 » Sun Dec 17, 2023 4:38 pm

I have a CEF C++ application that creates multiple browser instances with unique clients and request contexts. All of the cache path variables (CefBrowserSettings cache_path + root_cache_path and CefRequestContext cache_path) are set to empty string. The deviceIds returned by Javascript navigator.mediaDevices.enumerateDevices() persist across browser instances, clearing cookies and restarting the application. I'm quite confused as I thought empty cache paths meant "incognito" mode, meaning the deviceIds wouldn't be shared between browser instances. In addition, msdn docs for MediaDeviceInfo deviceId say the following "[deviceId] is reset when the user clears cookies. For private browsing, a different identifier is used that is not persisted across sessions", both of which seems to be contradicted by what I'm experiencing. Is chrome's implementation of MediaDeviceInfo that different from firefox? Am I missing something, for example not setting cache_path correctly to have incognito mode? How can I reset these deviceIds and/or avoid having them shared between browser instances?

I'm on ubuntu, CEF 117.0.0-master.2827+gcab4045+chromium-117.0.5938.0

Any help is much appreciated.
Last edited by turtle1 on Sun Dec 17, 2023 9:04 pm, edited 4 times in total.
turtle1
Newbie
 
Posts: 9
Joined: Wed Sep 20, 2023 3:45 pm

Re: mediaDevices deviceId persists across browser instances

Postby turtle1 » Sun Dec 17, 2023 6:11 pm

Okay after some testing in chrome I guess this is just how chrome / chromium behaves wrt deviceId?
Incognito tabs have different ids than the normal browser, but they're the same across different incognito tabs. the ids for non-incognito tabs also persist after closing the browser.
Clearing all cookies changes the ids in chrome, but that is not something I've been able to replicate in CEF.
turtle1
Newbie
 
Posts: 9
Joined: Wed Sep 20, 2023 3:45 pm

Re: mediaDevices deviceId persists across browser instances

Postby turtle1 » Sun Dec 17, 2023 7:04 pm

https://www.w3.org/TR/mediacapture-stre ... o-deviceid

If the User Agent chooses not to clear the identifier in this condition, then it MUST provide for the user to visibly inspect and delete the identifier, like a cookie.
Since deviceId may persist across browsing sessions and to reduce its potential as a fingerprinting mechanism, deviceId is to be treated as other persistent storage mechanisms such as cookies [COOKIES], in that User Agents MUST NOT persist device identifiers for sites that are blocked from using cookies, and User Agents MUST rotate per-origin device identifiers when other persistent storage are cleared.(This is a fingerprinting vector.)


How do I clear deviceIds in CEF?
turtle1
Newbie
 
Posts: 9
Joined: Wed Sep 20, 2023 3:45 pm

Re: mediaDevices deviceId persists across browser instances

Postby turtle1 » Sun Dec 17, 2023 7:42 pm

with --enable-chrome-runtime, the deviceIds change every time the app starts (but still shared across tabs), so I guess this is alloy specific.
turtle1
Newbie
 
Posts: 9
Joined: Wed Sep 20, 2023 3:45 pm

Re: mediaDevices deviceId persists across browser instances

Postby turtle1 » Sun Dec 17, 2023 9:41 pm

I think I solved it.
I hard coded "allowed" to be false in AlloyContentBrowserClient::GetMediaDeviceIDSalt.
Now deviceIDs are unique per application run and per browser instance.

EDIT: well, it's not exactly what I wanted, the ID is also different every time you load the page in same browser instance.
turtle1
Newbie
 
Posts: 9
Joined: Wed Sep 20, 2023 3:45 pm


Return to Support Forum

Who is online

Users browsing this forum: No registered users and 211 guests