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

[v2, linux] Improve switching to main thread for callbacks #1392

Merged

Conversation

stffabi
Copy link
Collaborator

@stffabi stffabi commented May 11, 2022

Make sure no pointers to the stack are passed to g_idle_add,
because at the time the callback gets executed on the
main thread, the pointer might be invalid.
Go might have reused the stack or grown the stack and the
pointer is invalid.

The concept used on Windows has been ported to Linux.

Potential fix for #1321

@leaanthony
Copy link
Member

Thanks for looking at this 👍 It looks fine to me. One thing I am starting to see is duplication between the different platform frontends and am wondering if we should think about moving some things to a common base... or whether that will bite us in the end :-)

@stffabi
Copy link
Collaborator Author

stffabi commented May 11, 2022

Thanks for looking into the PR.

One thing I am starting to see is duplication between the different platform frontends and am wondering if we should think about moving some things to a common base... or whether that will bite us in the end :-)

Yeah absolutely would be great to reduce those duplications 👍 .

@stffabi stffabi force-pushed the feature/linux-improve-main-thread-invokes branch 2 times, most recently from 56dce16 to 23e84b8 Compare May 19, 2022 07:55
@leaanthony
Copy link
Member

What do we need to get this out of draft? 😄

@stffabi
Copy link
Collaborator Author

stffabi commented May 28, 2022

Not much, basically just changing the return values to void for those native methods. I'll try to clean that up during the next couple of days

@stffabi stffabi force-pushed the feature/linux-improve-main-thread-invokes branch from c87d1fe to c3b5426 Compare May 31, 2022 05:59
@stffabi stffabi changed the title [v2, linux] Draft: Improve switching to main thread for callbacks [v2, linux] Improve switching to main thread for callbacks May 31, 2022
@stffabi stffabi marked this pull request as ready for review May 31, 2022 06:10
@stffabi stffabi requested a review from leaanthony May 31, 2022 06:10
Make sure no pointers to the stack are passed to g_idle_add,
because at the time the callback gets executed on the
main thread, the pointer might be invalid.
Go might have reused the stack or grown the stack and the
pointer is invalid.

The concept used on Windows has been ported to Linux.
@stffabi stffabi force-pushed the feature/linux-improve-main-thread-invokes branch from c3b5426 to 6ddc13f Compare May 31, 2022 06:11
@leaanthony
Copy link
Member

Looks great! Thanks for doing this. Let's see if this helps #1321

@leaanthony leaanthony merged commit 2a0673f into wailsapp:master May 31, 2022
@stffabi stffabi deleted the feature/linux-improve-main-thread-invokes branch May 31, 2022 11:59
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.

2 participants