asciidoctor-intellij-plugin
asciidoctor-intellij-plugin copied to clipboard
Preview takes long time to initialize after the update
Description
Seems like a local issue since nobody else reported it. I wanted to share my case of preview taking a long time to initialize after the plugin update.
First noticed it a couple versions before, but then preview initiated by itself after half an hour. After recent update to 0.37.35 preview didn't want to initialize at all. I restarted IDE, restarted the plugin, disabled the plugin, then restarted IDE, then restarted again and enabled the plugin. Only the double restart cured the preview. Don't know what's causing it. Maybe I need to clear the cache or something?
IntelliJ IDEA 2022.2 (Community Edition) Build #IC-222.3345.118, built on July 26, 2022 Runtime version: 17.0.3+7-b469.32 amd64 VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o. Windows 10 10.0 GC: G1 Young Generation, G1 Old Generation Memory: 4086M Cores: 8 Non-Bundled Plugins: org.asciidoctor.intellij.asciidoc (0.37.36)
Kotlin: 222-1.7.10-release-334-IJ3345.118
Thanks for bringing this up and sorry to hear that this is causing you troubles.
A restart of the IDE should only be necessary after upgrading the plugin. If indexes need to be rebuilt, this will happens automatically.
The preview might take longer to appear when IntelliJ's indexing of the project takes place - still the preview should appear while indexing is still running. In all other cases this shouldn't occur.
It is definitely worth analyzing; sometimes a specific projects points out some weakness in the plugin. Once that it solved, it will be faster for all users.
The reasons why the preview doesn't appear can be either something that is blocked, or something that takes too long to compute. A thread dump will shed some light on the first kind of causes, while profiling will provide information in both situations.
If something is blocked, a thread dump might provide the necessary information. See https://intellij-support.jetbrains.com/hc/en-us/articles/206544899 on how to create a thread dump. Afterwards, please send the thread dump to me via email (you'll find my email address in my GitHub profile).
If something takes too long to compute, CPU profiling might lead to the cause. See https://intellij-support.jetbrains.com/hc/en-us/articles/207241235 in chapter "The CPU usage is high or IDE is slow" for more information. Unfold the details below "2019.2 and above". As you're using the IntelliJ Community Edition, install the Performance Testing plugin first. Afterwards, please send the profiling file to me via email (you'll find my email address in my GitHub profile).
I'm looking forward to find out what's going on there.
I have sent you an email with the requested data.
I found out some more details about this scenario. Preview is not initialized every time IDE reloaded.
Every time I close all tabs, then reload IDE and open the tabs again, preview initializes right away.
I'm not sure yet why this happens. I found that one event wasn't processed as as the preview wasn't visible yet, this should now be fixed as part of pre-release 0.37.38. You might now see a preview earlier, and then a refresh of the preview once the indexing is complete / the IDE is no longer in dumb mode.
Could you please give it a try?
The pre-release of the plugin is available from GitHub releases and the IntelliJ AsciiDoc EAP repository.
The fix doesn't seem to help anything. Preview is still initialized only after all tabs are closed and IDE restarted.
Sorry this didn't help. I also had a look at the files you sent and didn't find exceptions. In dump3.txt
I found that one thread was initializing AsciidoctorJ, and another one was waiting approx. 12 seconds for that to complete. The first rendering of the first preview is expected to take some seconds (but not minutes) to initialize AsciidoctorJ and the JRuby runtime. All other renderings will be faster (sub-second).
Maybe it is time to check some assumptions / asking some stupid questions here:
- Please add a screenshot how it looks like when you wait for the preview to initialize.
- Are you running the IDE in "Project" mode, or in "Light Edit" mode?
- What happens if you close and re-open an editor where the preview is stalled in initializing - it is then appearing?
- Do you see a high CPU usage of the IDE?
- Please send the log file of your IDE to me via email. Maybe there's an stack trace or other information hiding in there to solve this.
- Do you happend to have friend or colleague who could try to debug the situation on your machine?
Thanks!
No problem, stupid questions are the way to go sometimes:
- Please add a screenshot how it looks like when you wait for the preview to initialize.
- I will attach short videos to demonstrate the behavior: Here I restarted IDE, preview is not visible: https://vimeo.com/736767285/bafced6d75 Here I restarted it again, no preview is visible: https://vimeo.com/736767614/2060d882fb Here I first try to open a new project while preview is not visible, then I restart the plugin and preview becomes visible: https://vimeo.com/736768419/00f52d3428 The key word is visible. It looks like the preview is generated and it is there, it's just not visible behind a "curtain". I can perfectly manipulate it, click anywhere and anything, even links will open. I just don't see it. -Are you running the IDE in "Project" mode, or in "Light Edit" mode?
- Project mode
- What happens if you close and re-open an editor where the preview is stalled in initializing - it is then appearing?
- Not, it's not.
- Do you see a high CPU usage of the IDE?
- Don't see.
- Please send the log file of your IDE to me via email. Maybe there's an stack trace or other information hiding in there to solve this.
- Done.
- Do you happend to have friend or colleague who could try to debug the situation on your machine?
- What kind of debugging do you have in mind?
Thanks for those details. It seems that the preview fails to initialize, as it is not showing the initial "Initializing..." message. The log file didn't reveal a clue for me.
This rules out some areas, including a CPU performance issue. You can now uninstall the performance plugin.
The problem might be somewhere in the JCEF initialization, or that it initializes/renders off-screen. A workaround might be to use the JavaFX preview - it is deprecated, and JetBrains might remove that functionality soon. You'll need to install the plugin "JavaFX for Plugins" first. See https://intellij-asciidoc-plugin.ahus1.de/docs/users-guide/features/preview/javafx-preview.html for more details.
Even if that workaround with JavaFX works for now, it is important to make this work with JCEF as this is the mode that will work with future versions as well.
Some more questions - some related with previous problems of JCEF. Even if some of them sound strange, please don't laugh:
- Do you happen to have multiple screens attached to you computer?
- Did you enable UI scaling (for example setting it to 150%)?
- If yes, which scaling did you use?
- What happens if the the preview didn't initialize, and you move the vertical separator between editor and preview with your mouse a little bit to the left or the right?
- What happens if you first close all AsciiDoc editors, then restart the IDE, and then open an AsciiDoc editor with a preview? Does that lead to the same situation where the preview is blank?
- There is a registry setting "ide.browser.jcef.asciidocView.osr.enabled" that is enabled by default. Does disabling this setting change the behavior? The registry is available via menu "Help | Find action…". Then enter “Registry” to search the action, then choose “Registry…”. In the dialog that opens, start typing the registry key given above to restrict the list. Un-Check the checkbox on the right to disabled it. Press Close to close the dialog. Then close the any AsciiDoc editor and re-open it. A restart of the IDE shouldn't be necessary. On the other hand if this doesn't work without a restart, consider a restart anyway to be sure,
I'm looking forward to the your answers. Thanks!
-
Do you happen to have multiple screens attached to you computer?
- No, just one.
-
Did you enable UI scaling (for example setting it to 150%)? If yes, which scaling did you use?
- I only set larger font:
- I only set larger font:
-
What happens if the the preview didn't initialize, and you move the vertical separator between editor and preview with your mouse a little bit to the left or the right?
- Nothing.
-
What happens if you first close all AsciiDoc editors, then restart the IDE, and then open an AsciiDoc editor with a preview? Does that lead to the same situation where the preview is blank?
- No, it's not blank. It initializes fine.
-
There is a registry setting "ide.browser.jcef.asciidocView.osr.enabled" that is enabled by default. Does disabling this setting change the behavior?
- No, it doesn't change the behavior. If preview is visible, it's still visible. After IDE restart with this setting disabled, the preview did not render. With this feature disabled and not visible preview, I went to the registry and restored the feature back. Then I got exception in IDEA core. Attaching the files below.
What happens if you first close all AsciiDoc editors, then restart the IDE, and then open an AsciiDoc editor with a preview? Does that lead to the same situation where the preview is blank? It initializes fine.
That's kind of promising. Could you please try what happens when closing all AsciiDoc editors except one, and then restarting the IDE? Maybe it's some kind of a race condition.
WRT to the exceptions you saw - I had a look and they are unrelated to the AsciiDoc plugin. I reproduced them locally and reported them via the automatic error reporting to JetBrains.
There is now pre-release 0.37.39 where I cleaned up the preview rendering from some workarounds, added some logging and deferred some of the initialization of the preview.
I'd be happy if you could give that version a try with restarting with no editor, one editor and more than one editor.
Thanks!
That's kind of promising. Could you please try what happens when closing all AsciiDoc editors except one, and then restarting the IDE? Maybe it's some kind of a race condition.
No, closing all but one makes no difference. When I restart IDE with any number of open editors, preview is not visible. Then when I close all editors without restarting IDE, then open any number of editors, preview is visible
There is now pre-release 0.37.39
This is interesting. On a new prerelease now I observe the following:
- Open one editor - restart IDE - no preview
- Open more than one editor - restart - no preview for all editors
The difference from my previous message is that I don't need to close all editors. I can close current tab, reopen it and preview will be visible. When I open new editor tab, preview becomes visible very soon.
After some IntelliJ and plugin updates, the preview usually initializes on all open tabs except the current one. It initializes if I reopen the current tab.
IntelliJ IDEA 2022.2.1 (Community Edition) Build #IC-222.3739.54, built on August 16, 2022 Runtime version: 17.0.3+7-b469.37 amd64 VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o. Windows 10 10.0 GC: G1 Young Generation, G1 Old Generation Memory: 4086M Cores: 8 Non-Bundled Plugins: org.asciidoctor.intellij.asciidoc (0.37.45)
Kotlin: 222-1.7.10-release-334-IJ3739.54
Thanks for the update ... I have to say that I ran out of ideas why this is happening.
The only solution is to watch, how this situation develops. Thanks for your will to help!
Updated the IntelliJ and the plugin to latest versions. The preview is invisible again. it's "behind the curtain " and didn't want to show up after I restarted the IDE. But I made it to show up by playing with preview/editor layout buttons.
Could that be an issue on IntelliJ side? Seems to be specific to work PC only, however.
It seems like this issue is not an AsciiDoc plugin issue, but rather an IDE issue. I raised a question in IntelliJ YouTrack.
The problem was caused by connecting to the PC via RDP on Windows. Who knew! Thanks for coming out to help!
Thanks for reporting this upstream and post the link to the solution here!
This now part of the docs, and I hope this solution helps others: https://intellij-asciidoc-plugin.ahus1.de/docs/users-guide/features/preview/jcef-preview.html#preview-not-showing-on-rdp-workaround-available