Fix race condition where not all logs would be added to the viewer.

This commit is contained in:
Greyson Parrelli
2025-08-13 21:43:01 -04:00
parent a34ccd8ce7
commit 33f7fdedfa
3 changed files with 29 additions and 18 deletions

View File

@@ -220,6 +220,11 @@ function applyFilter() {
editor.setValue(filtered, -1);
}
function appendLines(lines) {
editor.session.insert({ row: editor.session.getLength(), column: 0}, lines);
logLines += lines;
}
function readLines(offset, limit) {
const lines = logLines.split("\n")
if (offset >= lines.length) {

View File

@@ -46,7 +46,11 @@ object DebugLogsViewer {
fun appendLines(webview: WebView, lines: String) {
// Set the debug log lines
val escaped = JSONObject.quote(lines)
ThreadUtil.runOnMain { webview.evaluateJavascript("editor.insert($escaped); logLines+=$escaped;", null) }
val latch = CountDownLatch(1)
ThreadUtil.runOnMain {
webview.evaluateJavascript("appendLines($escaped)") { latch.countDown() }
}
latch.await()
}
@JvmStatic