kotlinx.html icon indicating copy to clipboard operation
kotlinx.html copied to clipboard

Breakpoint in HTML DSL with Ktor-Server causes IntelliJ Debugger to hog memory and hang with "Collecting data" message

Open lehnerpat opened this issue 4 years ago • 0 comments

Reproduction Steps

  • Have a Gradle project with Kotlin (JVM), Ktor and ktor-html-builder / kotlinx-html open in IntelliJ IDEA
  • Use call.respondHtml() to build the response using HTML DSL, as describe here on the Ktor docs
  • Place a breakpoint somewhere in the HTML DSL (see screenshot for example)
    • Note: this is inside of a suspend function
  • Trigger the route with a matching request

Expected Result

  • The IDE stops at the breakpoint
  • The debugger shows the values of any variables in scope in the "Variables" section, like any other regular breakpoint

Actual Result

  • The IDE stops at the breakpoint
  • The debugger shows the (names of the) variables in the "Variables" section
  • But no values are shown at first; instead, the text "Collecting data..." is shown
  • (Note: in some situations, I have observed that not even the list of variables is shown immediately, instead showing a single "Collecting data..." in its place)
  • The debugger takes several minutes, during which CPU usage is very high (>80% of multiple cores) and memory usage keeps increasing (the IDE shows a hint at some point that its allocated memory is insufficient). hanging-debugger

Further Notes

  • I have not been able to isolate this issue to just Ktor or just kotlinx-html (or just the IDE). So far, I've only observed it in this combination.
  • Since I wasn't able to isolate the root of this issue, I've also submitted this as a ticket to Ktor (ktorio/ktor#1911) and to the IntelliJ IDEA tracker (JB YouTrack IDEA-242236)

Version Info:

  • OS: macOS 10.15.4
  • IDE: IntelliJ IDEA 2020.1.1 (Community Edition) (Build #IC-201.7223.91, Runtime version: 11.0.6+8-b765.40 x86_64, VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o)
  • JDK: adopt-openjdk-1.8.0_252
  • Kotlin: observed on 1.3.70 and 1.3.72
  • Ktor-server: 1.3.2 with ktor-server-netty engine
  • kotlinx-html: 0.7.1

Reproduction Example

lehnerpat avatar Jun 01 '20 09:06 lehnerpat