From 0be3492e071551d49cbe4a10e098384b55382c4a Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Fri, 2 Aug 2019 08:54:21 +0200 Subject: [PATCH] ui/app: (wasm) avoid deadlock from focus changes showTextInput is called from the window loop in window.go, but could result in an immediate event which then deadlocks waiting for the window loop to handle it. Signed-off-by: Elias Naur --- ui/app/os_js.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/ui/app/os_js.go b/ui/app/os_js.go index 17962edd..33f92155 100644 --- a/ui/app/os_js.go +++ b/ui/app/os_js.go @@ -318,11 +318,15 @@ func (w *window) setAnimating(anim bool) { } func (w *window) showTextInput(show bool) { - if show { - w.focus() - } else { - w.blur() - } + // Run in a goroutine to avoid a deadlock if the + // focus change result in an event. + go func() { + if show { + w.focus() + } else { + w.blur() + } + }() } func (w *window) draw(sync bool) {