-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
electron: use inversify in main process #7964
Conversation
26ba1dd
to
90007cd
Compare
@akosyakov here is Electron to use inversify. This commit adds the bare minimum required to run Electron, as well as a communication scheme between frontend and electron main process (via No communication is happening between electron main process and the backend process at the moment. My concern in that regard is that the backend heavily pollutes its stdout/stderr, so I am not really sure it would be possible to use those streams for IPC. But I also don't see a use for such a communication right now? |
Are we waiting for #7968 before considering this PR? |
Yes, please. Of course, if you have a very good reason, we can start with this, but first, it should be marked as ready for the review. As for the verification, I want to extend the APIs you have created and want to add support for the |
I just want either you or Anton to go over the new contributions points and messaging utilities to make sure the design is ok. I didn't want to get crazy with a design that would be refused. If the current approach is fine with you, I can clean the PR and mark it as ready for final review.
I am sorry, I don't understand what you mean. Are you asking if you will be able to add support for |
Yes.
No no, it's out of context. |
Hm, I am not familiar with what using |
@kittaakos I don't see anything that would prevent it, as it seems it doesn't require changes to the Electron main process logic to work. Correct me if I am wrong. |
You do not have to, just if you're interested. Here is an example, I want to see the notifications about new updates, do you want to install and so on in the Theia notification center, and not some native dialogs. So that's why your change is super important. Without injection, it is not possible. |
From that example, it seems like you will be able to nicely use it after this patch. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a few comments. I am going to start with the integration and see how it works. What I definitely miss is the electron application as an argument to the start
, stop
, and hookApplicationEvents
methods. Let me check how well does the API work during the integration.
dev-packages/application-manager/src/generator/frontend-generator.ts
Outdated
Show resolved
Hide resolved
I am experiencing #6499 again. If I refresh the browser window, the |
@marechal-p, please help me with this. I have tried to add a new extension that contributes to the new
...
"dependencies": {
"@theia/core": "^1.2.0",
"@theia/electron": "^1.2.0"
},
"theiaExtensions": [
{
"electronMain": "lib/electron-main/update/electron-updater-module"
}
],
...
import { ContainerModule } from 'inversify';
import { ElectronApplicationContribution } from '@theia/electron/lib/electron-main/electron-application';
import { ElectronUpdaterContribution } from './electron-updater-contribution';
export default new ContainerModule(bind => {
bind(ElectronApplicationContribution).to(ElectronUpdaterContribution).inSingletonScope();
});
import { injectable } from 'inversify';
import { ElectronApplicationContribution } from '@theia/electron/lib/electron-main/electron-application';
@injectable()
export class ElectronUpdaterContribution implements ElectronApplicationContribution {
async start(): Promise<void> {
console.log('start');
}
async stop(): Promise<void> {
console.log('stop');
}
} And in the diff --git a/examples/electron/package.json b/examples/electron/package.json
index e2dddb190..405bbf2b1 100644
--- a/examples/electron/package.json
+++ b/examples/electron/package.json
@@ -22,6 +22,7 @@
"@theia/editor": "^1.2.0",
"@theia/editor-preview": "^1.2.0",
"@theia/electron": "^1.2.0",
+ "@theia/electron-api-samples": "^1.2.0",
"@theia/file-search": "^1.2.0",
"@theia/filesystem": "^1.2.0",
"@theia/getting-started": "^1.2.0", I pushed the code to https://github.com/eclipse-theia/theia/compare/electron-updater-example |
b3a027c
to
d4ebff3
Compare
@kittaakos thank you very much for the review, it's encouraging! I still need to investigate the issues you reported about the connection not being closed, as well as why contributions are not picked up. |
d4ebff3
to
c796cc7
Compare
I am not sure if this is an issue with the changeset, or I misunderstood something. 👍 The PR looks very promising, let me know if you need someone to try it out again. |
It's done. I have verified the electron-main contributions and the dummy updater. It was OK. |
I'm ok with the current changes, let's get this merged right after the release? I'll need someone to approve since I cannot do it on my own PRs :) |
I totally agree. Let's schedule another review after 30.7.
Same for me. 😄 |
@marechal-p, do you have time to update this PR from the |
I am going to take care of the update. |
24c8747
to
d8a2a2f
Compare
I did the update:
I gave the app another try on macOS with Node.js
I reviewed @marechal-p's contribution several times by drafting the following PRs:
Here is another one: The changes from the PRs as mentioned above had been merged back to here. Here is another review from Windows env. Thanks a lot for your help, @mcgordonite 👍 I am going to leave this PR open for another few days then I'll merge it without further notice. Let me know if anyone has any concerns. |
d8a2a2f
to
a3fb16d
Compare
a3fb16d
to
3b700e9
Compare
Just tested on Windows that we can launch the Electron app and open new windows. There was a bug where the maximized state was not applied back, I just pushed the fix for it. |
Thanks for the heads-up and the fix, @marechal-p. I did not know we planned to change it. What about these: theia/dev-packages/application-manager/src/generator/frontend-generator.ts Lines 192 to 197 in 6086b28
I could not find the corresponding logic in the new code. Did we just lose the Added ability to change windowOptions & it's defaults feature? |
@kittaakos the mechanism for changing default options is simply different now: One has to rebind the (It was also one of the reason why this refactoring was needed: the old mechanism was waiting for the frontend to send a message back to the electron main process in order to drive it, now you can directly add the logic within) |
3b700e9
to
eb1cc99
Compare
@kittaakos at the very least I added back the window options coming from the package.json configuration field. When I first started the PR a lot of patches were not merged so these things must have slept through, my bad. |
We cannot break existing behavior. It was not even mentioned anywhere.
No. It is not simply different. A downstream Theia consumer could define window properties at build time in the Could you please make this PR compliment with the |
This has been brought back. theia/dev-packages/application-manager/src/generator/frontend-generator.ts Lines 309 to 314 in 6086b28
@kittaakos regarding the workaround IPC code, is it ok in this case to make this breaking change? When I mentioned getting rid of it to @owlJaeger that made the PR to introduce it he seemed favorable to the idea. I think that it would be better to get rid of workarounds. |
I do not mind, but you have to ask the community. |
eb1cc99
to
79c3ad8
Compare
Mentions of the IPC events being temporary:
Going through with this change then. |
I do not mind it breaking the currently used workarounds. I am looking forward to switching to the extensible solution by rebinding |
We have a conflict again. I am going to make another rebase and merge it tomorrow. Update: it's done. |
All the logic for the electron main process currently has to be added to our generators, making it hard to extend without committing to Theia. This commit re-arranges the way Electron is launched to allow people to more easily change the behavior of their application. Add a basic CLI to open a workspace by doing `app path/to/workspace`. CLI can be overriden by application makers by extending and rebinding `ElectronApplication.launch` and handling yourself the `ExecutionParams`. Added a dummy electron-updater sample. Breaking-Change: Removed the `set-window-options` and `get-persisted-window-options-additions` Electron IPC handlers from the Electron Main process. Signed-off-by: Paul Maréchal <paul.marechal@ericsson.com> Co-Authored-By: Akos Kitta <kittaakos@typefox.io>
79c3ad8
to
99d88d2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for all of you helping with this PR. Special thanks to @marechal-p for initiating this change.
If you discover any regressions, please file a bug and name me. Thanks!
Closes #3364
Closes #7406
Closes #7964
Combined work with @kittaakos.
What it does
This PR contributes a JSON-RPC communication scheme between the
electron-main
process and therenderer
processes. It is reusing the same architecture as the websocket-based connection between frontend/backend, but adapted to work over electron's ipc apis. Currently there isn't scoped connections, meaning that each renderer process will interact with the same singleton in the electron-main process, but for the current use-cases this is sufficient.How to test
To verify:
yarn --cwd ./examples/electron start
-> Should open previous workspace, if any. Otherwise, opens a no-workspace app.yarn --cwd ./examples/electron start ~/Desktop/
-> Opens your app with a workspace to theDesktop
.yarn --cwd ./examples/electron start ../..
-> Opens the app to with Theia as the workspace.yarn --cwd ./examples/electron start path/to/missing
-> Opens the app without a workspace. See log:Could not resolve the workspace path.
mkdir ~/Desktop/path\ with\ space && yarn --cwd ./examples/electron start ~/Desktop/path\ with\ space
-> Open the app with the desired workspace. The workspace contains spaces in the FS path.File
>Settings
>Check for Update...
-> You will see, there are no updates.Disposed a sample updater client.
ANDRegistered a new sample updater client.
Registered a new sample updater client.
. Close the new window, you should seeDisposed a sample updater client.
Review checklist
Reminder for reviewers