Skip to content
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

Upgrade to Electron 7 #1543

Merged
merged 6 commits into from Nov 2, 2019
Merged

Upgrade to Electron 7 #1543

merged 6 commits into from Nov 2, 2019

Conversation

fxha
Copy link
Contributor

@fxha fxha commented Oct 26, 2019

Q A
New feature? yes
License MIT

Description

  • Upgrade to Electron 7
  • Added window zoom and enabled printing.
  • Listen for system theme changes for all OSs.
  • Set Chromium's dark mode for native element for dark themes.
    • Default value for autoSwitchTheme is 1 to not confuse the user that the theme is always changed when a different OS and Mark Text is used (dark vs light).

resolved #749
resolved #1225

@fxha fxha requested a review from Jocs October 26, 2019 19:04
@fxha
Copy link
Contributor Author

fxha commented Oct 26, 2019

@Jocs There is an issue that unlimited Mark Text instances are spawned when running E2E tests.

Edit: Fixed.

@Jocs
Copy link
Member

Jocs commented Oct 27, 2019

It's not related this issue, but I think maybe we need this API for some cases of communication between main and renderer process.

屏幕快照 2019-10-27 上午9 01 04

@Jocs
Copy link
Member

Jocs commented Oct 27, 2019

@fxha I can no longer change the theme by theme menu now, I change the theme to light and it will change back to dark, when the system theme is dark mode.

@fxha
Copy link
Contributor Author

fxha commented Oct 27, 2019

It's not related this issue, but I think maybe we need this API for some cases of communication between main and renderer process.

I think we don't really need these APIs because all remote functions that we use have to be synchronous like minimize a window or show a context menu.

I can no longer change the theme by theme menu now, I change the theme to light and it will change back to dark, when the system theme is dark mode.

The issue should be fixed now but I'll open an Electron issue about the API design.

@Jocs
Copy link
Member

Jocs commented Oct 28, 2019

I can not start up by yarn dev after I pull this PR to my computer, it stoped at the init page.
屏幕快照 2019-10-28 上午10 51 51

@fxha
Copy link
Contributor Author

fxha commented Oct 28, 2019

@Jocs Please run yarn to install dependencies, I replaced node-spellchecker with my fork to successfully compile it with latest Node/V8. Otherwise press CmdOrCtrl+Alt+I to get the stack trace.

@Jocs
Copy link
Member

Jocs commented Oct 29, 2019

@fxha I have removed the node_modules run yarn , but I still can not start dev Mark Text, I even can not open Chrome devtools by press CmdOrCtrl+Alt+I. there is also no error in terminal.

@fxha
Copy link
Contributor Author

fxha commented Oct 29, 2019

Maybe some issues with Electron 7 and macOS on main process that not all Mark Text modules are loaded such as the menu due to an exception? Please try to debug this (e.g. attach to main process via Chromium debug tools). There also some known issues like all developement tools extensions doesn't work and there are strange warnings about deprecated APIs on Windows that we didn't use. There should be at least the following warning:

Electron: Loading non context-aware native modules in the renderer process is deprecated and will stop working at some point in the future, please see electron/electron#18397 for more information

@Jocs
Copy link
Member

Jocs commented Oct 29, 2019

Actually, I didn't understand the code logic here, but I felt that there was some problem, because we modified the value of themeSource, which caused the new event updated to be triggered, and then changed the value of themeSource again, thus causing an infinite loop.

截屏2019-10-29下午10 44 30

And I modified some codes to avoid the infinity loop, and it works(the added codes maybe not good)

截屏2019-10-29下午10 45 17

@fxha
Copy link
Contributor Author

fxha commented Oct 29, 2019

@Jocs I understand the code logic neither, neither upstream nor the event code really. I think we should drop support for automatically theme detection at runtime and only adjust it at application start. It's also not possible on macOS >=10.15 to detect the OS theme color when manually setting theme mode to either light or dark according Electron answer. I'll write another comment that the method has very bad behavior across different OSs but I'll not spend more time to fix the bullshit function because it behaves different on Linux, macOS and Windows. Are you fine to drop support for it?

Edit: Fixing one issue will cause more issues on different OSs and maybe it will depend on the OS and Chromium version too - who knows.

@Jocs
Copy link
Member

Jocs commented Oct 29, 2019

Are you fine to drop support for it?

I am Ok, maybe we need to open an issue to Electron a description of what we encountered?

@Jocs
Copy link
Member

Jocs commented Oct 29, 2019

A feature request is also needed to open in our issues, I think, to track this problem.

@fxha
Copy link
Contributor Author

fxha commented Oct 29, 2019

I am Ok, maybe we need to open an issue to Electron a description of what we encountered?

I already ask for a function to get the OS theme mode but that's not possible due to changes in macOS 10.15. I also recommended some documentation changes but maybe the observed behavior is just a bug.

@fxha
Copy link
Contributor Author

fxha commented Nov 1, 2019

@Jocs I have removed runtime native theme detection and it should work now.

@fxha fxha added the 🔍 need review This PR need review label Nov 1, 2019
@Jocs
Copy link
Member

Jocs commented Nov 1, 2019

截屏2019-11-02上午1 52 50

The UI in Theme tab page is broken.

@fxha
Copy link
Contributor Author

fxha commented Nov 2, 2019

@Jocs Please create a PR for this or post the adjusted CSS because I already fixed this for Linux and Windows but macOS seems to use another window bounds.

@fxha
Copy link
Contributor Author

fxha commented Nov 2, 2019

@Jocs There are strange errors in logs/main.log since Electron 7 like 32767. Does this also occur on macOS?

@Jocs
Copy link
Member

Jocs commented Nov 2, 2019

Please create a PR for this or post the adjusted CSS because I already fixed this for Linux and Windows but macOS seems to use another window bounds.

Ok, I'll submit a PR after this PR merged.

There are strange errors in logs/main.log since Electron 7 like 32767. Does this also occur on macOS?

Can you paste the error message or show me a screenshot, Where can I find the strange errors?

@fxha
Copy link
Contributor Author

fxha commented Nov 2, 2019

Can you paste the error message or show me a screenshot, Where can I find the strange errors?

I already found the source. It was an issue with keytar that we cannot decrypt the GitHub token.

@fxha fxha merged commit 09f920e into develop Nov 2, 2019
@fxha fxha deleted the electron-upgrade branch November 2, 2019 15:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔍 need review This PR need review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Some menu entries doesn't work as expected Print callback is not called when cancelling the print dialog
2 participants