Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why webview Destroy() does not close webview window in both Linux and Windows environments? #588

Open
s-matsushita-iij opened this issue Jun 24, 2021 · 4 comments · May be fixed by #849
Open
Assignees

Comments

@s-matsushita-iij
Copy link

What OS are you using (uname -a, or Windows version)?

Both Linux and Windows.

Linux:
Linux shougo-GE 5.4.0-74-generic #83-Ubuntu SMP Sat May 8 02:35:39 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

Windows:
Windows 10 Enterprise 21H1

IE version: 11.789.19041.0
Edge: 91.0864.54

What programming language are you using (C/C++/Go/Rust)?

go version go1.16.5 linux/amd64
go version go1.16 windows/amd64

What did you expect to see and what you saw instead?

Expected: Destroy() should close webview window.

I have tested below sample script.
Destroy() is called after 5 seconds sleep, but the webview window does not be closed.
The window is only closed when the script is exited.

package main

import (
	"fmt"
	"time"

	"github.com/webview/webview"
)

func main() {
	runBrowser()

	fmt.Println("destroyed!")
	time.Sleep(5 * time.Second)
	fmt.Println("exit!")
}

func runBrowser() {
	debug := true
	w := webview.New(debug)
	defer w.Destroy()
	w.SetTitle("Minimal webview example")
	w.SetSize(800, 600, webview.HintNone)
	w.Navigate("http://www.google.co.jp/")

	go func() {
		fmt.Println("Closing in 5 seconds")
		time.Sleep(5 * time.Second)

		w.Dispatch(func() {
			w.Terminate()
		})
	}()

	w.Run()
}

I have read the code and it should close the window when Destroy() is called.

Destroy()

And in macOS the webview window close seems implemented.

~cocoa_wkwebview_engine() { close(); }

Note: The destructor is called when Destroy() is called.

The behavior is changed when the code is merged?
843c3aa#diff-0332cdfa0ecdb4d0b79f675f5079e61cdc3e7f6f3c658a73c64973a1b35c2442

Related issue: #514
I think the above issue works because it is under macOS environment.

@mkishi
Copy link

mkishi commented Jun 30, 2021

Currently, I am facing the same issue. I really hope it will be fixed.

@cipheras
Copy link

Same issue for me too. I am running webview in a thread and Destroy() is not closing the window.

@cgostuff
Copy link
Contributor

Same issue here. Destroy executes and has no effect, window won't close until i cross it out myself.

@justjosias justjosias changed the title Why webview Destroy() does not close weview window in both Linux and Windows environments? Why webview Destroy() does not close webview window in both Linux and Windows environments? May 24, 2022
@eftomi
Copy link

eftomi commented Feb 10, 2023

Is someone solving this problem for Windows? I see that Linux PR is not accepted yet.

@SteffenL SteffenL self-assigned this Feb 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

7 participants