Skip to content

Fix EDT violation in course additional files check #5

@meanmail

Description

@meanmail

Overview

File I/O operations are being performed on the EDT (Event Dispatch Thread) during course update checks, which can freeze the UI.

Location

File: intellij-plugin/hs-core/src/org/hyperskill/academy/learning/stepik/hyperskill/update/HyperskillCourseUpdater.kt
Function: needUpdateCourseAdditionalFiles (lines 313-334)

Problem

The function file.loadEncodedContent() is wrapped in runWriteAction inside invokeAndWaitIfNeeded, which blocks the EDT. This is called in a loop during course update checks and can cause UI freezes.

val localFileContent = invokeAndWaitIfNeeded {
    runWriteAction {
        file.loadEncodedContent()
    }
}

What needs to be fixed

  • Move file reading operations to a background thread using ReadAction.compute() or ReadAction.nonBlocking()
  • Keep only actual write operations in write actions
  • The function is called in a loop, so the performance impact is significant
  • Ensure proper threading model: IO operations should not block EDT

Tests understanding of

  • EDT vs background thread operations
  • ReadAction / WriteAction proper usage
  • invokeAndWaitIfNeeded gotchas
  • File system operations threading requirements
  • Smart mode awareness

Validation

  • Run IDE with the plugin and trigger course updates
  • Ensure no UI freezes occur during course synchronization
  • Add/modify tests to verify the fix

Estimated time

3-5 hours

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions