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
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.ktFunction:
needUpdateCourseAdditionalFiles(lines 313-334)Problem
The function
file.loadEncodedContent()is wrapped inrunWriteActioninsideinvokeAndWaitIfNeeded, which blocks the EDT. This is called in a loop during course update checks and can cause UI freezes.What needs to be fixed
ReadAction.compute()orReadAction.nonBlocking()Tests understanding of
ReadAction/WriteActionproper usageinvokeAndWaitIfNeededgotchasValidation
Estimated time
3-5 hours