Skip to content

fix(webview): route javascript: URLs through evaluateJavascript in the dispatcher#18

Open
jim-daf wants to merge 1 commit into
cerisara:masterfrom
jim-daf:fix-dispatcher-evaluatejs
Open

fix(webview): route javascript: URLs through evaluateJavascript in the dispatcher#18
jim-daf wants to merge 1 commit into
cerisara:masterfrom
jim-daf:fix-dispatcher-evaluatejs

Conversation

@jim-daf
Copy link
Copy Markdown

@jim-daf jim-daf commented May 15, 2026

Closes #17.

GoJsActivity runs every script call into the EidoGo board through a single dispatcher (viewerq -> runOnUiThread -> wv.loadUrl(surl)). All the viewUrl("javascript:...") call sites end up there, so the actual WebView call is loadUrl("javascript:...") for every move state change. That's the legacy pattern: it adds a synthetic history entry on every script eval and cannot return a value to the caller.

There's already a long comment block in this file pointing at evaluateJavascript as the KitKat-era replacement. The swap at the dispatcher covers every existing call site without touching them individually:

if (surl != null && surl.startsWith("javascript:")) {
    GoJsActivity.main.wv.evaluateJavascript(
            surl.substring("javascript:".length()), null);
} else {
    GoJsActivity.main.wv.loadUrl(surl);
}

Non-javascript URLs still go through loadUrl exactly as before. The null callback keeps behaviour identical for the script branch since no existing call site reads a return value.

…the dispatcher

GoJsActivity dispatches every script call into the EidoGo board
through a single queue + runOnUiThread + wv.loadUrl(surl) pipeline.
Most viewUrl(...) call sites push a 'javascript:...' URL into that
queue, so the actual WebView call is loadUrl('javascript:...') on
every move state change. That records a synthetic history entry
every time and has no callback shape.

The file already has a long comment block noting evaluateJavascript
is the KitKat-era replacement. Doing the swap at the dispatcher
covers every existing viewUrl call site without touching them. Non
javascript URLs still go through loadUrl exactly as before.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GoJsActivity dispatcher uses loadUrl("javascript:...") for every board state change

1 participant