Comments (6)
When an existing window isn't passed to the C function webview_create
then it doesn't just create a new window, it also wants to take the responsibility of managing the application's lifecycle.
It's probably crashing when attempting to register the custom app delegate class a second time with the same class name.
from webview.
I can reproduce the issue on macOS.
No issues to spawn multiple windows on Linux or Windows.
from webview.
Hey @trufae,
Can you provide a minimal example of the code you are using to create multiple windows? Please also system information, e.g. via v doctor
. Then it'll become a bit easier to look into the issue.
from webview.
Sure, this is the source, crash and doctor:
0$ v run dos.v
signal 11: segmentation fault
0 libsystem_platform.dylib 0x0000000180e42a24 _sigtramp + 56
1 dos 0x00000001004d3df0 _ZN7webview6detail22cocoa_wkwebview_engine19create_app_delegateEv + 308
2 dos 0x00000001004d3df0 _ZN7webview6detail22cocoa_wkwebview_engine19create_app_delegateEv + 308
3 dos 0x00000001004d3894 _ZN7webview6detail22cocoa_wkwebview_engineC2EbPv + 104
4 dos 0x00000001004d3808 _ZN7webview7webviewC2EbPv + 72
5 dos 0x00000001004d25bc _ZN7webview7webviewC1EbPv + 56
6 dos 0x00000001004d24ec webview_create + 56
7 dos 0x000000010050a8fc webview__create + 64
8 dos 0x000000010050ac28 main__main + 56
9 dos 0x000000010050afa8 main + 84
10 dyld 0x0000000180abbf28 start + 2236
139$
5$ cat dos.v
import webview
fn main() {
w := webview.create()
w2 := webview.create()
w.run()
w2.run()
}
0$ v doctor
V full version: V 0.4.0 56644b2
OS: macos, macOS, 13.4.1, 22F82
Processor: 10 cpus, 64bit, little endian, Apple M1 Max
getwd: /Users/pancake/prg/v-test
vexe: /Users/pancake/prg/v/v
vexe mtime: 2023-08-18 09:00:46
vroot: OK, value: /Users/pancake/prg/v
VMODULES: OK, value: /Users/pancake/.vmodules
VTMP: OK, value: /tmp/v_501
Git version: git version 2.39.2 (Apple Git-143)
Git vroot status: weekly.2023.30-165-g56644b2b (2 commit(s) behind V master)
.git/config present: true
CC version: Apple clang version 14.0.3 (clang-1403.0.22.14.1)
thirdparty/tcc status: thirdparty-macos-arm64 a668e5a0
0$
from webview.
With the lifecycle separation implemented in webview/webview#1005 it's possible to spawn multiple windows.
Example:
import webview
const doc = '<button onclick="window.new_window();">New window</button>'
fn main() {
w := webview.create()
w.set_title('Primary Window')
w.set_size(480, 320, .@none)
w.set_html(doc)
w.bind('new_window', fn (e &webview.Event) voidptr {
e.dispatch(fn () {
w2 := webview.create()
w2.set_title('Secondary Window')
w2.set_size(480, 320, .@none)
w2.set_html('Secondary Window')
})
return webview.no_result
})
w.run()
}
If you run into errors despite having re-run the build.vsh
, you might need to clean your vmodules cache. E.g. by removing the .vmodules/cache
directory.
from webview.
Awesome!
from webview.
Related Issues (11)
- Add an example that uses a framework like astro or SvelteKit
- Time-consuming functions will block application responsiveness. HOT 2
- Disable developer tools
- Windows support
- [Question] Change default icon of application HOT 4
- bug: debug not working on macOS HOT 1
- bug: Blank window from 'webkitgtk2-4.1' bug (with temporary fix) HOT 2
- ld: library not found for -lstdc++ HOT 2
- feat: menu items on Mac (maybe also other OSs?) HOT 4
- feat: Do you have any plans to implement borderless windows?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from webview.