activeTab permissions issue in tabCapture

687 views
Skip to first unread message

Nitesh Gupta

unread,
Mar 13, 2024, 8:57:54 AMMar 13
to Chromium Extensions
Basically this is my use case :
  • According to particular tabId using the chrome.tabCapture.getMediaStreamId I want to get streamId out of it.
  • Then send this streamId in the offscreen doc
  • Now using the navigator.mediaDevices.getUserMedia I want to get the media streams
Following the above while using the chrome.tabCapture getting the below error :
Unchecked runtime.lastError: Extension has not been invoked for the current page (see activeTab permission). Chrome pages cannot be captured.

I have tried removing and attaching the activeTab permission but ending up with the same error.
However I have other permissions in-place like tabCapture, tabs.

Oliver Dunk

unread,
Mar 13, 2024, 9:03:27 AMMar 13
to Nitesh Gupta, Chromium Extensions
Hi Nitesh,

For calling tabCapture.capture, there are two important requirements:
  • It needs to be called in response to a user gesture, for example `.addEventListener("click")` in a content script or `action.onClicked` in the background. There are some additional examples here.
  • It needs to be done synchronously - you can't do so inside an async function, or in a callback.
Is it possible you are not meeting one of these? If you can share more about how you triggered the call, that might help to provide more specific suggestions.

We also have a sample which shows how to do this from start to finish which you might want to look at: https://github.com/GoogleChrome/chrome-extensions-samples/tree/main/functional-samples/sample.tabcapture-recorder
Oliver Dunk | DevRel, Chrome Extensions | https://developer.chrome.com/ | London, GB


--
You received this message because you are subscribed to the Google Groups "Chromium Extensions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extens...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/cfa7789c-661c-448e-9845-7f6c103fbdafn%40chromium.org.

Nitesh Gupta

unread,
Mar 13, 2024, 2:53:55 PMMar 13
to Chromium Extensions, Oliver Dunk
Actually I want to get the streamId from a particular tabId that I am passing into a function not from the chrome action. So is there any way to use chrome.tabCapture.getMediaStreamId that fulfils the above scenario.

Particular steps are as follows of my use case :
  •  Inside the service worker according to particular tabId using the chrome.tabCapture.getMediaStreamId I want to get streamId out of it.
  • Then send this streamId in the offscreen doc
  • Now using the navigator.mediaDevices.getUserMedia I want to get the media streams

Oliver Dunk

unread,
Mar 21, 2024, 4:45:10 PMMar 21
to Nitesh Gupta, Chromium Extensions
Hi Nitesh,

It isn't possible to do this without a user gesture unfortunately. You can use the getDisplayMedia web API, but that requires the user to explicitly select a tab.
Oliver Dunk | DevRel, Chrome Extensions | https://developer.chrome.com/ | London, GB

b t

unread,
May 10, 2024, 6:43:13 AMMay 10
to Chromium Extensions, Nitesh Gupta
Has it finally been achieved


r:

Oliver Dunk

unread,
May 10, 2024, 6:49:35 AMMay 10
to b t, Chromium Extensions, Nitesh Gupta
Hi,

There isn't anything new here - we continue to support passing streams to an offscreen document, but there is a user gesture requirement for getMediaStreamId().

I hope this helps.
Oliver Dunk | DevRel, Chrome Extensions | https://developer.chrome.com/ | London, GB

--
You received this message because you are subscribed to the Google Groups "Chromium Extensions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extens...@chromium.org.
Reply all
Reply to author
Forward
0 new messages