The chrome.desktopCapture API call (https://developer.chrome.com/docs/extensions/reference/desktopCapture/#method-chooseDesktopMedia) suggests that targetTab is an optional parameter. If we do not provide the parameter, the media source could only be retrieved by the origin of the Chrome Extension.
In order to skip this parameter, I use undefined as a placeholder. The script is running in a background.js (which is called a Service Worker since Manifest V3):
chrome.desktopCapture.chooseDesktopMedia(["screen", "window"], undefined, function(streamid) {
// communicate this string to the app so it can call getUserMedia with it
message.type = 'screen_record_reply';
message.streamId = streamid;
callback(message);
return false;
});
This crashes my browser, before even showing me the media selector (where you select which / what screen you want to share).
If I properly define a targetTab (by calling chrome.tabs.query with an active flag, it will work (although the media resource could be retrieved by the origin of the active tab as well).
Am I triggering unwanted behavior by providing undefined as an optional parameter value, and am I supposed to do something else to indicate that I do not want to provide the optional targetTab parameter?
from Calling chrome.desktopCapture API without optional tab parameter crashes browser
No comments:
Post a Comment