Repository navigation
Closed
Description
Preflight Checklist
- I have read the Contributing Guidelines for this project.
- I agree to follow the Code of Conduct that this project adheres to.
- I have searched the issue tracker for an issue that matches the one I want to file, without success.
Issue Details
- Electron Version:
- 8.0.2 (also checked on 8.2.5.)
- Operating System:
- Windows 10 Pro (1903)
- Last Known Working Electron version:
Expected Behavior
The menu is created without any errors
Actual Behavior
Error:
render.js:48 Uncaught (in promise) Error: Could not call remote method 'buildFromTemplate'. Check that the method signature is correct. Underlying error: Error processing argument at index 1, conversion failure from
Underlying stack: TypeError: Error processing argument at index 1, conversion failure from
at Menu../lib/browser/api/menu.js.Menu.insert (electron/js2c/browser_init.js:1855:23)
at Menu../lib/browser/api/menu.js.Menu.append (electron/js2c/browser_init.js:1835:15)
at electron/js2c/browser_init.js:1913:12
at Array.forEach (<anonymous>)
at Function../lib/browser/api/menu.js.Menu.buildFromTemplate (electron/js2c/browser_init.js:1909:10)
at electron/js2c/browser_init.js:6745:67
at IpcMainImpl.<anonymous> (electron/js2c/browser_init.js:6610:27)
at IpcMainImpl.emit (events.js:210:5)
at WebContents.<anonymous> (electron/js2c/browser_init.js:3873:23)
at WebContents.emit (events.js:210:5)
at electron/js2c/browser_init.js:6748:21
at IpcMainImpl.<anonymous> (electron/js2c/browser_init.js:6610:27)
at IpcMainImpl.emit (events.js:210:5)
at WebContents.<anonymous> (electron/js2c/browser_init.js:3873:23)
at WebContents.emit (events.js:210:5)
getVideoSources @ render.js:48
async function (async)
getVideoSources @ render.js:32
To Reproduce
$ git clone https://github.com/dropsonic/223-electron-screen-recorder.git -b master
$ npm install
$ npm startPress 'Choose a Video Source' button.
The code:
async function getVideoSources() {
const inputSources = await desktopCapturer.getSources({
types: [ 'window', 'screen' ],
fetchWindowIcons: true
});
const videoOptionsMenu = Menu.buildFromTemplate(
inputSources.map((source) => {
return {
label: source.name,
icon: source.appIcon,
click: () => selectSource(source)
};
})
);
videoOptionsMenu.popup();
}Screenshots
Additional Information
I've also tried to set nativeImage.createEmpty() as an icon but got the same error.
Metadata
Metadata
Assignees
Labels
No labels

Activity
codebytere commentedon May 12, 2020
@dropsonic in the short term, remove the icons from the MenuItems and that'll fix it. This seems to be caused by a conversion error borne of the fact that the sources returned from
desktopCapturer.getSourcescontain invalidappIcons. I'll try to look further into it.dropsonic commentedon May 12, 2020
@codebytere it looks like it is not related to
desktopCapturer.getSourcesbecause if I usenativeImage.createEmpty()as an icon I get the same error.codebytere commentedon May 12, 2020
@dropsonic yep, exactly. The invalidity is that some of them are empty.
dropsonic commentedon May 12, 2020
@codebytere oh, now I see. So it means that if I define icons for menu items, I have to define a valid icon for each item?
icon: !source.appIcon || source.appIcon.isEmpty() ? undefined : source.appIcon,doesn't help either.According to the log,
desktopCapturer.getSourcesreturns several items with non-empty images, some items with empty images (appIcon.isEmpty()returnstrue) and some items withnullappIcon.codebytere commentedon May 12, 2020
@dropsonic i think the root of this issue may lie with us :) I'll do some digging and see what i find.
codebytere commentedon May 12, 2020
@dropsonic i've determined the underlying issue and opened a PR. Feel free to follow the above linked PR to track it to a release once it's merged :)
dropsonic commentedon May 13, 2020
@codebytere wow, that was blazingly fast. Thanks a lot!