laravel-query-intellij icon indicating copy to clipboard operation
laravel-query-intellij copied to clipboard

Attempt to fix UI freeze

Open ekvedaras opened this issue 11 months ago • 1 comments

Attempting to use ReadAction.nonBlocking and Disposable

ekvedaras avatar Mar 11 '24 17:03 ekvedaras

ReadAction.nonBlocking<Unit> {
     TableAndAliasCollector(this).collect()
     DbReferenceResolver(this).resolve()
}.inSmartMode(project).expireWith(expressionDisposable).executeSynchronously()

It means that the actions inside ReadAction.nonBlocking block will be executed on the current thread, therefore tests and following actions during plugin execution will wait till the end of ReadAction.nonBlocking

The tests will be passed, but make sure that

TableAndAliasCollector(this).collect()
DbReferenceResolver(this).resolve()

is an idempotent operations block, because ReadAction.nonBlocking will be restarted on any UI actions (typing, etc.)

smirok avatar Apr 26 '24 07:04 smirok

How did I miss .executeSynchronously()... 🙈

ekvedaras avatar Jun 24 '24 19:06 ekvedaras

@ekvedaras Hi! The fact that this approach did not lead to the problem's fix means that you probably do not have enough cancellation points in the code (https://plugins.jetbrains.com/docs/intellij/general-threading-rules.html#read-action-cancellability). Please try to use ProgressManager.checkCanceled() between DB calls. For example, you could use it as a first command in every iteration of forEach-es in DbReferenceResolver.kt.

smirok avatar Jul 02 '24 09:07 smirok