Skip to content

Requested device not found when using chrome.tabCapture.capture #3651

@s16h

Description

@s16h

Steps to reproduce

Tell us about your environment:

  • Puppeteer version: 1.11.0
  • Platform / OS version: MacOS Mojave 10.14.1
  • URLs (if applicable):
  • Node.js version: v10.12.0

What steps will reproduce the problem?

Please include code that reproduces the issue.

  1. Create a Chrome extension that uses chrome.tabCapture.capture in background.js:
// background.js

function startRecording() {
    chrome.tabCapture.capture(options, stream => {
        if (stream === null) {
            console.log(`Last Error: ${chrome.runtime.lastError.message}`);
            return;
        }
        try {
            const recorder = new MediaRecorder(stream);
        } catch (err) {
            console.log(err.message);
            return;
        }
        recorder.addEventListener('dataavailable', event => {
            console.log(`Got another blob.`);
        });
        const timeslice = 60 * 1000;
        recorder.start(timeslice);
    });
}
  1. In the Puppeteer script, load the extension.

  2. In the Puppeteer script, make sure you're listening to console events:

const targets = await browser.targets();
const backgroundPageTarget = targets.find(target => target.type() === 'background_page' && target.url().startsWith('chrome-extension://abcde/'));
const backgroundPage = await backgroundPageTarget.page();

backgroundPage.on('console', msg => {
    for (let i = 0; i < msg.args().length; ++i) {
        console.log(`${i}: ${msg.args()[i]}`);
    }
});
  1. In the Puppeteer script, access the extension's background page, and invoke the function in background.js that calls chrome.tabCapture.capture:
...

const test = await backgroundPage.evaluate(() => {
    startRecording();
    return Promise.resolve(42);
});

...

What is the expected result?

I would expect to start seeing a series of Got another blob.s outputted to the console. In other words, a non-null stream parameter.

What happens instead?

Last Error: Requested device not found gets outputted to the console. In other words, the stream parameter of chrome.tabCapture.capture's callback is null.

Metadata

Metadata

Assignees

No one assigned

    Labels

    chromiumIssues with Puppeteer-Chromium

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions