electron-userland / electron-spellchecker

Implement spellchecking, correctly
MIT License
237 stars 83 forks source link

Performance Issues #95

Open ccorcos opened 6 years ago

ccorcos commented 6 years ago

I'm having issues where the spellchecker takes up huge frames.

I'm Mac Sierra btw.

image

ccorcos commented 6 years ago

If I spam on my application ( you can find it at www.notion.so/desktop ), you'll see that the spellchecker runs every time I press space.

However in Atom, it doesn't run the spell checked until I stop typing:

ccorcos commented 6 years ago

I filed an issue with Electron because I think it might be on their end: https://github.com/electron/electron/issues/10734

anaisbetts commented 6 years ago

tbh, the core issue is that Electron's spellchecker API is a synchronous API - we must immediately return a response, and especially on macOS, NSSpellchecker sometimes randomly decides to be very slow. Making the spellchecker API async would make solving this issue much easier.

ccorcos commented 6 years ago

So this is much faster on an older version of the app:

image

When Xcode developer tools upgraded with macOS High Sierra, I had to upgrade everything in order for the build to work and now its way slower... Perhaps some bindings broke and isn't able to use the native spellchecker anymore...?

zhenchaoli commented 6 years ago

Is the synchronized API electron specific or imposed by Chromium? Reason I'm asking is that in WebKit's WebSpellCheckClient definition, there's a requestCheckingOfText which seems to be async. But maybe it's just we can't run js in chrome's worker thread?

Edit: I see that in the impl for this requestCheckingOfText API in electron, we are synchronously calling into V8 to call our spellchecker provider's method. And it's difficult to run it on worker thread because main thread has exclusive access to v8.