YunaBraska / github-workflow-plugin

Your Ultimate Wingman for GitHub Workflows and Actions! 🚀
https://github.com/YunaBraska/github-workflow-plugin
Apache License 2.0
47 stars 11 forks source link

UI unresponsive on start due to GitHubSchemaProvider.getSchemaFile #34

Closed dekimsey closed 1 year ago

dekimsey commented 1 year ago

What happened? When I open a project the UI is unresponsive for a noticeable amount of time.

How can we reproduce the issue? Steps to reproduce the behavior:

  1. Open GHA project

Relevant log output

log excerpt

``` 2023-10-11 11:58:50,088 [ 2631] INFO - #com.github.yunabraska.githubworkflow.helper.GitHubWorkflowHelper - Download [https://json.schemastore.org/dependabot-2.0] 2023-10-11 11:58:50,796 [ 3339] INFO - #c.i.u.i.UnindexedFilesScanner - Scanning completed for jubilant-goggles. Number of scanned files: 19105; Number of files for indexing: 6 took 1585ms; general responsiveness: 1/1 sluggish; EDT responsiveness: ok 2023-10-11 11:58:50,796 [ 3339] INFO - #c.i.u.i.UnindexedFilesScanner - 10408fc5: marking roots for initial VFS refresh 2023-10-11 11:58:50,800 [ 3343] INFO - #c.i.u.i.UnindexedFilesScanner - 10408fc5: starting initial VFS refresh 2023-10-11 11:58:50,803 [ 3346] INFO - #c.i.u.i.UnindexedFilesScanner - 10408fc5: initial VFS refresh finished 2 ms 2023-10-11 11:58:50,809 [ 3352] INFO - #c.i.o.p.MergingQueueGuiExecutor - Task finished: UnindexedFilesScanner[jubilant-goggles] 2023-10-11 11:58:55,624 [ 8167] INFO - #com.github.yunabraska.githubworkflow.helper.GitHubWorkflowHelper - Download [https://json.schemastore.org/github-action] 2023-10-11 11:58:58,471 [ 11014] WARN - #c.i.o.p.i.ProjectFrameAllocator - Cannot load project in 10 seconds: ... 2023-10-11 11:58:58,681 [ 11224] INFO - #c.i.w.i.i.j.s.JpsGlobalModelSynchronizerImpl - Loading global entities from files 2023-10-11 11:59:00,886 [ 13429] INFO - #com.github.yunabraska.githubworkflow.helper.GitHubWorkflowHelper - Download [https://json.schemastore.org/github-funding] 2023-10-11 11:59:06,092 [ 18635] INFO - #com.github.yunabraska.githubworkflow.helper.GitHubWorkflowHelper - Download [https://json.schemastore.org/github-workflow] 2023-10-11 11:59:11,360 [ 23903] INFO - #com.github.yunabraska.githubworkflow.helper.GitHubWorkflowHelper - Download [https://json.schemastore.org/github-discussion] 2023-10-11 11:59:16,626 [ 29169] INFO - #com.github.yunabraska.githubworkflow.helper.GitHubWorkflowHelper - Download [https://json.schemastore.org/github-issue-forms] 2023-10-11 11:59:21,886 [ 34429] INFO - #com.github.yunabraska.githubworkflow.helper.GitHubWorkflowHelper - Download [https://json.schemastore.org/github-issue-config] 2023-10-11 11:59:27,163 [ 39706] INFO - #com.github.yunabraska.githubworkflow.helper.GitHubWorkflowHelper - Download [https://json.schemastore.org/github-workflow-template-properties] 2023-10-11 11:59:32,490 [ 45033] WARN - #c.i.d.PerformanceWatcherImpl - UI was frozen for 41680ms, details saved to /Users/daniel.kimsey/Library/Logs/JetBrains/GoLand2023.2/threadDumps-freeze-20231011-115855-GO-232.9921.53-Unsafe.park-41sec ```

Thread dumps show multiple threads all BLOCKED attempting to pull the Schema from schemastore.org, with one in WAITING:

"DefaultDispatcher-worker-32" prio=0 tid=0x0 nid=0x0 waiting on condition
     java.lang.Thread.State: WAITING
 on java.util.concurrent.FutureTask@460373
        at java.base@17.0.8/jdk.internal.misc.Unsafe.park(Native Method)
        at java.base@17.0.8/java.util.concurrent.locks.LockSupport.park(LockSupport.java:211)
        at java.base@17.0.8/java.util.concurrent.FutureTask.awaitDone(FutureTask.java:447)
        at java.base@17.0.8/java.util.concurrent.FutureTask.get(FutureTask.java:190)
        at com.github.yunabraska.githubworkflow.helper.FileDownloader.downloadContent(FileDownloader.java:62)
        at com.github.yunabraska.githubworkflow.services.GitHubActionCache.lambda$getSchema$6(GitHubActionCache.java:104)
        at com.github.yunabraska.githubworkflow.services.GitHubActionCache$$Lambda$2879/0x0000000801316240.get(Unknown Source)
        at java.base@17.0.8/java.util.Optional.or(Optional.java:313)
        at com.github.yunabraska.githubworkflow.services.GitHubActionCache.getSchema(GitHubActionCache.java:104)
        at com.github.yunabraska.githubworkflow.services.GitHubActionCache.getSchema(GitHubActionCache.java:116)
        at com.github.yunabraska.githubworkflow.model.GitHubSchemaProvider.lambda$getSchemaFile$1(GitHubSchemaProvider.java:55)
        at com.github.yunabraska.githubworkflow.model.GitHubSchemaProvider$$Lambda$2863/0x0000000801314998.get(Unknown Source)
        at java.base@17.0.8/java.util.Optional.orElseGet(Optional.java:364)
        at com.github.yunabraska.githubworkflow.model.GitHubSchemaProvider.getSchemaFile(GitHubSchemaProvider.java:54)
        at com.jetbrains.jsonSchema.impl.JsonSchemaServiceImpl.getSchemaForProvider(JsonSchemaServiceImpl.java:595)
        at com.jetbrains.jsonSchema.impl.JsonSchemaServiceImpl$MyState.createFileProviderMap(JsonSchemaServiceImpl.java:569)
        at com.jetbrains.jsonSchema.impl.JsonSchemaServiceImpl$MyState.lambda$new$0(JsonSchemaServiceImpl.java:518)
        at com.jetbrains.jsonSchema.impl.JsonSchemaServiceImpl$MyState$$Lambda$2444/0x00000008013c2540.invoke(Unknown Source)
        at com.intellij.util.concurrency.SynchronizedClearableLazy._get_value_$lambda$1$lambda$0(SynchronizedClearableLazy.kt:41)
        at com.intellij.util.concurrency.SynchronizedClearableLazy$$Lambda$28/0x0000000800115d58.apply(Unknown Source)
        at java.base@17.0.8/java.util.concurrent.atomic.AtomicReference.updateAndGet(AtomicReference.java:210)
        at com.intellij.util.concurrency.SynchronizedClearableLazy.getValue(SynchronizedClearableLazy.kt:40)
        at com.jetbrains.jsonSchema.impl.JsonSchemaServiceImpl.getProvidersForFile(JsonSchemaServiceImpl.java:251)
        at com.jetbrains.jsonSchema.impl.JsonSchemaServiceImpl.getSchemasForFile(JsonSchemaServiceImpl.java:184)
        at com.jetbrains.jsonSchema.impl.JsonSchemaServiceImpl.getSchemaFilesForFile(JsonSchemaServiceImpl.java:154)
        at com.jetbrains.jsonSchema.widget.JsonSchemaStatusWidget.doGetWidgetState(JsonSchemaStatusWidget.java:215)
        at com.jetbrains.jsonSchema.widget.JsonSchemaStatusWidget.calcWidgetState(JsonSchemaStatusWidget.java:206)
        at com.jetbrains.jsonSchema.widget.JsonSchemaStatusWidget.getWidgetState(JsonSchemaStatusWidget.java:155)
        at com.intellij.openapi.wm.impl.status.EditorBasedStatusBarPopup$doUpdate$state$1.invoke(EditorBasedStatusBarPopup.kt:148)
        at com.intellij.openapi.wm.impl.status.EditorBasedStatusBarPopup$doUpdate$state$1.invoke(EditorBasedStatusBarPopup.kt:147)
        at com.intellij.openapi.application.rw.InternalReadAction.insideReadAction(InternalReadAction.kt:105)
        at com.intellij.openapi.application.rw.InternalReadAction.access$insideReadAction(InternalReadAction.kt:14)
        at com.intellij.openapi.application.rw.InternalReadAction$tryReadCancellable$2.invoke(InternalReadAction.kt:95)
        at com.intellij.openapi.application.rw.InternalReadAction$tryReadCancellable$2.invoke(InternalReadAction.kt:94)
        at com.intellij.openapi.application.rw.CancellableReadActionKt$cancellableReadActionInternal$1.invoke$lambda$1$lambda$0(cancellableReadAction.kt:41)
        at com.intellij.openapi.application.rw.CancellableReadActionKt$cancellableReadActionInternal$1$$Lambda$1386/0x0000000800d20e38.run(Unknown Source)
        at com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:1133)
        at com.intellij.openapi.application.rw.CancellableReadActionKt$cancellableReadActionInternal$1.invoke$lambda$1(cancellableReadAction.kt:39)
        at com.intellij.openapi.application.rw.CancellableReadActionKt$cancellableReadActionInternal$1$$Lambda$1385/0x0000000800d20bf0.run(Unknown Source)
        at com.intellij.openapi.progress.util.ProgressIndicatorUtilService.runActionAndCancelBeforeWrite(ProgressIndicatorUtilService.java:63)
        at com.intellij.openapi.progress.util.ProgressIndicatorUtils.runActionAndCancelBeforeWrite(ProgressIndicatorUtils.java:133)
        at com.intellij.openapi.application.rw.CancellableReadActionKt$cancellableReadActionInternal$1.invoke(cancellableReadAction.kt:37)
        at com.intellij.openapi.progress.CoroutinesKt.blockingContext(coroutines.kt:248)
        at com.intellij.openapi.application.rw.CancellableReadActionKt.cancellableReadActionInternal(cancellableReadAction.kt:34)
        at com.intellij.openapi.application.rw.InternalReadAction.tryReadCancellable(InternalReadAction.kt:94)
        at com.intellij.openapi.application.rw.InternalReadAction.tryReadAction(InternalReadAction.kt:76)
        at com.intellij.openapi.application.rw.InternalReadAction.readLoop(InternalReadAction.kt:63)
        at com.intellij.openapi.application.rw.InternalReadAction.access$readLoop(InternalReadAction.kt:14)
        at com.intellij.openapi.application.rw.InternalReadAction$readLoop$1.invokeSuspend(InternalReadAction.kt)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
        at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:584)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:793)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:697)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:684)

Operating System

OS X, Apple M1 Pro

Plugin Version

3.0.3

IDE Name and Version

GoLand 2023.2.2

Expected behavior UI should not be unresponsive.

Screenshots None.

Additional context This is a new install of the plugin.

schemastore.org appears to be having an outage right now. Requests are 502ing (GoLand's own built-in polling) or long response time.

Aside, I am using a custom GH Action/Workflow Schema to provide syntax highlighting, will these imported schemas break that once they are able to be pulled?

YunaBraska commented 1 year ago

Oh, no! That shouldn't happen! I am really sorry for that! It could because of the outage as I download the Workflow schemas which is a workaround until JetBrains does it (I need to check this again). Anyway, I will have a look as soon as I find time, it's a really embarrassing bug! Thank you for reporting this!!!

Is the installed Plugin version really that old (1.13.4)?

| Aside, I am using a custom GH Action/Workflow Schema to provide syntax highlighting, will these imported schemas break that once they are able to be pulled? Wow, I like to see this "x-intellij-language-injection": "Shell Script" (But it can be also PowerShell?) I have no idea how you use this without using master from schemastore.org. My plugin adds Schemas but doesn't overwrite them. So I would guess you can switch between your and my provided schemas

dekimsey commented 1 year ago

Oh, no! That shouldn't happen! I am really sorry for that

No worries, it happens! Thank you for acknowledging the report so quickly :)!

Is the installed Plugin version really that old (1.13.4)?

D'oh. Read the wrong plugin's version. It should be 3.0.3. I'll correct the report.

Wow, I like to see this "x-intellij-language-injection": "Shell Script" (But it can be also PowerShell?)

Sort of yes, however unfortunately IDEA-279710 makes it not possible to have a shell-specific entry. So the schema has to hardcode one shell or the other. (I linked to both schemas I tried in the IntelliJ ticket). I don't use PowerShell, so I'm not sure what the correct keyword is. I'm guessing one would need a PowerShell extension to provide it.

That being said it does work with the vanilla schemastore if one is willing to add the language injection comment before the blocks, like such:

  steps:
     # language=python
     - shell: python
        run: ....
YunaBraska commented 1 year ago

Unfortunately, I have no idea about your work, but if schemastrore.org does not merge your awesome work or JetBrains does not fix it, then we could try to work on a solution within this plugin. Just don't know how jet ^^

YunaBraska commented 1 year ago

Version 3.0.4 is on the way. I really appreciate your report!

YunaBraska commented 1 year ago

Fix is being rolled out.

The schemas are now preloaded and are always updated by newer versions. This is at least a relief, and I could if even adjust the schemas at any time. Preloaded Schemas The problem was, by not having control over the schema loading, I assumed that the JetBrains would run background processes asynchronously and not blocking. There are some designs that are really questionable in plugin development.

dekimsey commented 1 year ago

Thank you very much, I super appreciate the quick turnaround!