enable(webContents) not working in preload script
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 25/100
- Issue type
- Bug
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- electron, javascript
- Domain
- desktop
Research direction
No source files or tests are named. Start by tracing the main-process BrowserWindow creation, the preload script, and the notification window's content-loading path; compare the enableRemoteModule and remoteMain.enable setups. Done means the notification window displays its content under the reported Electron versions without console errors.
Written by the indexing model from the issue text.
Description
Hello everyone.
I am new on electron and trying to update an electron project from v11.5.0 to latest version (or at least last 17 sub version).
My setup:
"node": "14.16"
"@electron/remote": "^2.0.8",
"electron": "^12.0.0", (same issue with 13.6.9 or 17.3.1)
I am facing an issue trying to move from enableRemoteModule (in BrowserWindow's webPreferences) to enable(webContents).
Here it is about a notification windows which should be opened and display the right content.
I stay on electron 12.0.0/13.6.9 in order to switch easily from one to the other.
Before (enableRemoteModule)
main:
win = new BrowserWindow({
...
webPreferences: {
webviewTag: true,
enableRemoteModule: true,
nativeWindowOpen: true,
contextIsolation: false,
preload: ...,
}
});
preload
const win = new remote.BrowserWindow({
...,
webPreferences: {
enableRemoteModule: true,
contextIsolation: false,
preload: ...,
}
});
After (enable)
main:
import * as remoteMain from '@electron/remote/main';
[...]
win = new BrowserWindow({
...
webPreferences: {
webviewTag: true,
nativeWindowOpen: true,
contextIsolation: false,
preload: ...,
}
});
remoteMain.enable(win.webContents)
preload:
const win = new remote.BrowserWindow({
...,
webPreferences: {
enableRemoteModule: true,
contextIsolation: false,
preload: ...,
}
});
remote.require("@electron/remote/main").enable(win.webContents);
I probably miss something important.
In preload.js, with enableRemoteModule: true, every thing works fine, my notification window open and is filled up with its content. Using enable, my notification window open but nothing is displayed in it. I do not have any console warning or error.
In main, using enable seems to work.
I guess it could be related to an initialization issue.
I do not know if it could help but I noticed that remoteMain.enable(win.webContents) in main returns null and remote.require("@electron/remote/main").enable(win.webContents) returns undefined in preload even if both emoteMain.enable and remote.require("@electron/remote/main").enable return the same exact function.
- Dominant language
- TypeScript
- Stars
- 411
- Forks
- 53
- Avg merge
- 3m
- Merged PRs (30d)
- 1
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from electron/remote
-
Difficulty 4/5 3-5 days Newbie friendliness 30/100
-
Difficulty 3/5 1-2 days Newbie friendliness 25/100
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
-
Difficulty 3/5 1-2 days Newbie friendliness 38/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
copse-dev/agent-pane#2953 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Eynzof/Hermes-CN-Desktop#610 ·
-
bug clawsweeper:linked-pr-open clawsweeper:needs-live-repro clawsweeper:no-new-fix-pr impact:message-loss issue-rating: 🐚 platinum hermit P2 regression
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
calcite-components needs triage refactor
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Esri/calcite-design-system#15203 ·