Skip to content

Commit 856f295

Browse files
whalechoibackslashxx
authored andcommitted
api: spawn CallbackList use UiThreadHandler::runAndWait executor (tiann#2096)
![jsexception](https://github.com/user-attachments/assets/e8a4744d-bd0a-40bf-869c-def915b66075) Because the exit callback in js cleans up the ChildProcess, when the last callback of stdout is executed after the exit callback, an error like “emitData ReferenceError: spawn_callback_1727358276092_68 is not defined” will occur.
1 parent 008958a commit 856f295

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

manager/app/src/main/java/me/weishu/kernelsu/ui/webui/WebViewInterface.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import androidx.core.view.WindowInsetsCompat
1414
import androidx.core.view.WindowInsetsControllerCompat
1515
import com.topjohnwu.superuser.CallbackList
1616
import com.topjohnwu.superuser.ShellUtils
17+
import com.topjohnwu.superuser.internal.UiThreadHandler
1718
import me.weishu.kernelsu.ui.util.listModules
1819
import me.weishu.kernelsu.ui.util.createRootShell
1920
import me.weishu.kernelsu.ui.util.withNewRootShell
@@ -110,13 +111,13 @@ class WebViewInterface(val context: Context, private val webView: WebView, priva
110111
}
111112
}
112113

113-
val stdout = object : CallbackList<String>() {
114+
val stdout = object : CallbackList<String>(UiThreadHandler::runAndWait) {
114115
override fun onAddElement(s: String) {
115116
emitData("stdout", s)
116117
}
117118
}
118119

119-
val stderr = object : CallbackList<String>() {
120+
val stderr = object : CallbackList<String>(UiThreadHandler::runAndWait) {
120121
override fun onAddElement(s: String) {
121122
emitData("stderr", s)
122123
}

0 commit comments

Comments
 (0)