Skip to content

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

Merged
leaanthony merged 1 commit into
wailsapp:masterfrom
stffabi:feature/linux-improve-main-thread-invokes
May 31, 2022
Merged

[v2, linux] Improve switching to main thread for callbacks#1392
leaanthony merged 1 commit into
wailsapp:masterfrom
stffabi:feature/linux-improve-main-thread-invokes

Conversation

@stffabi

@stffabi stffabi commented May 11, 2022

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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

stffabi commented May 11, 2022

Copy link
Copy Markdown
Contributor Author

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
Copy Markdown
Member

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

@stffabi

stffabi commented May 28, 2022

Copy link
Copy Markdown
Contributor Author

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
Copy Markdown
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