-
Notifications
You must be signed in to change notification settings - Fork 6k
[Linux] fix: make textures thread-safe on linux #40478
[Linux] fix: make textures thread-safe on linux #40478
Conversation
|
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat (don't just cc him here, he won't see it! He's on Discord!). If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
7244d58 to
6cc750d
Compare
robert-ancell
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change looks good, thanks! Just some details.
3d5a544 to
d27e24e
Compare
|
Golden file changes have been found for this pull request. Click here to view and triage (e.g. because this is an intentional change). If you are still iterating on this change and are not ready to resolve the images on the Flutter Gold dashboard, consider marking this PR as a draft pull request above. You will still be able to view image results on the dashboard, commenting will be silenced, and the check will not try to resolve itself until marked ready for review. |
69884cc to
8d32cc7
Compare
8d32cc7 to
ba7423e
Compare
ba7423e to
665e35a
Compare
|
Golden file changes are available for triage from new commit, Click here to view. |
90104b2 to
2f14fa7
Compare
|
Golden file changes are available for triage from new commit, Click here to view. |
robert-ancell
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look great now, thanks!
We've encountered some memory corruption when developing
RustDesk, which is an open-source remote desktop built with Flutter, and it uses the texture API provided by Flutter to provide the remote screen to clients.Both Windows and macOS work well, except for Linux. Sometimes random crashes will show and print different stack traces in these conditions:
markAvaliableThe runtime often complains

double free or corruption.One of the stack traces using lldb-10:
We checked the implementation of calling textures API on Linux several times, but have no luck.
We've noticed that on Linux, textures are organized by
g_hash_table, which is not the thread-safe hashtable and we should ensure synchronization on different threads. Also, we noticed the textures map on Windows already has the synchronization (for exampleengine/shell/platform/windows/flutter_windows_texture_registrar.cc
Lines 87 to 90 in 2c342a8
We add the synchronization by declaring a
GMutex, which is a mutex provided by GTK, in this PR. It can makeg_hash_tablethread-safe in different threads(ui, raster, etc).Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.