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

Access window size on closing #573

Closed
mrzv opened this issue Jul 17, 2020 · 9 comments
Closed

Access window size on closing #573

mrzv opened this issue Jul 17, 2020 · 9 comments

Comments

@mrzv
Copy link

mrzv commented Jul 17, 2020

Specification

  • pywebview version: 3.3.1
  • platform / version: macOS 10.15.5

Description

I'm new to pywebview, and I'm trying to figure out the right way to do the following. I'd like to save the shape of the window (width and height), when the window is closed or closing. The problem is that when I try to do this from a callback (added to window.closing), everything hangs. I think there is a deadlock somewhere, but I don't quite understand the design.

What's the right way to do this?

I can access width and height from the function f I pass to webview.start(f, window), but that doesn't solve the issue of how to trigger this logic when the window is closing.

@r0x0r
Copy link
Owner

r0x0r commented Jul 19, 2020

This is clearly a bug. The code invoked by on_closing is executed in a separate thread and is invoked after window is already closed.
I think this can be resolved with an additional lock just to handle the closing case.

@mrzv
Copy link
Author

mrzv commented Jul 19, 2020

Good to know. Thanks for looking into it. I wasn't sure if I was misunderstanding something, or if it was a bug.

Is there a good way to save the window shape on closing until this is fixed, or am I better off just waiting?

@r0x0r
Copy link
Owner

r0x0r commented Jul 21, 2020

I will try to fix this asap. Meanwhile the best course solution would be periodically save window dimensions somewhere and read the final value on window closing. Stupid, but it should work.

@r0x0r
Copy link
Owner

r0x0r commented Jul 21, 2020

@mrzv
I pushed a fix for Cocoa to the closing-fix branch. Window dimensions and position should be accessible during window.closing event. Invoking other methods might still result in a deadlock though.
Other platforms are not checked yet

@mrzv
Copy link
Author

mrzv commented Jul 21, 2020

Thanks!

@r0x0r
Copy link
Owner

r0x0r commented Jul 22, 2020

PR here #575

@mrzv
Copy link
Author

mrzv commented Jul 22, 2020

I should probably mention that I had the same deadlock, when I tried to read the shape of the window from window.closed. I don't know if it's relevant and the PR fixes both cases, but just FYI.

@r0x0r r0x0r closed this as completed in c0ba525 Jul 27, 2020
@mrzv
Copy link
Author

mrzv commented Jul 27, 2020

c0ba525 fixed window.closing event, but not window.closed. That one still causes a deadlock.

@r0x0r
Copy link
Owner

r0x0r commented Jul 28, 2020 via email

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

No branches or pull requests

2 participants