-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
[Linux] Run glib event loop on dedicated glib Matter context #25960
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@yzm157 can you verify on your side whether this PR fixes the issue with Qt? |
arkq
changed the title
Glib matter context
[Linux] Run glib event loop on dedicated glib Matter context
Apr 4, 2023
PR #25960: Size comparison from d81d4e3 to 2f96585 Decreases (1 build for cc32xx)
Full report (1 build for cc32xx)
|
PR #25960: Size comparison from d81d4e3 to 58ba991 Full report (1 build for cc32xx)
|
Looks like it works, works well. |
pullapprove
bot
requested review from
amitnj,
andy31415,
anush-apple,
bzbarsky-apple,
carol-apple,
chrisdecenzo,
chshu,
chulspro,
cliffamzn,
Damian-Nordic,
dhrishi,
electrocucaracha,
emargolis,
franck-apple,
gjc13,
harimau-qirex,
harsha-rajendran,
hawk248,
jelderton and
jepenven-silabs
April 12, 2023 11:15
pullapprove
bot
requested review from
vivien-apple,
woody-apple,
xylophone21,
younghak-hwang,
yufengwangca and
yunhanw-google
April 12, 2023 11:16
All D-Bus proxy objects created with GLib *_new_for_bus and *_new_for_bus_sync functions have to be created with thread default main context set. Otherwise, proxy object internal signals will be scheduled on GLib global main context. We do not want that, because we do not know whether Matter SDK will be used in GLib-based application or not, so we can not run global main even loop on our own - all Matter-related GLib signals shell be run on a dedicated Matter GLib context.
arkq
force-pushed
the
glib-matter-context
branch
from
April 14, 2023 08:01
2f8e778
to
ec685cd
Compare
PR #25960: Size comparison from 62974a0 to ec685cd Increases (1 build for cc32xx)
Full report (1 build for cc32xx)
|
andy31415
reviewed
Apr 14, 2023
PR #25960: Size comparison from de0dfcf to a84d073 Decreases (1 build for cc32xx)
Full report (1 build for cc32xx)
|
andy31415
approved these changes
May 9, 2023
tianfeng-yang
referenced
this pull request
May 10, 2023
…is started (#26338) * chip-repl hits the Code is unsafe/racy assert when BLE commissioning is started * Add lock/unlock to CancelTimer * Fix a few other issue * Restyle * Small fix * Last few fixes
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
Currently Linux uses GLib global main context when running main even loop. This causes issues with glib-based applications which use default main context in their global main event loop. Such an example is a Linux application based on Qt (Qt on Linux runs GLib global main context in order to link seamlessly with glib-based libraries). The problem is that on Linux platform
chip::DeviceLayer::PlatformManagerImpl::_InitChipStack()
waits until main event loop is ready to process events on given context (currently, global context). E.g.:See this for reference: #23320 (comment)
This PR is a follow-up for #25916
Changes
g_idle_add()
org_io_add_watch_full()
can not be used any more)g_main_context_get_thread_default()
was set in all places whereg_signal_connect()
or GIO call are madeTesting
Tested Python bindings:
Tested BLE commissioning with
Postscriptum
For anyone reading this description because of some break caused by this PR:
In order to quickly verify that the problem is with glib global main context, one can add this snippet at the beginning of
PlatformManagerImpl::_InitChipStack()
:If this will help, it means that somewhere there is a source attached to the glib global main context. The next step is to find this place and use
GLibMatterContextAttachSource()
if applicable or run particular block of code withGLibMatterContextInvokeSync()
. For finding GIO calls attached to glib global main context, one can usegdb -x <script> --args <cmd>
with script: