openframeworks / openFrameworks

openFrameworks is a community-developed cross platform toolkit for creative coding in C++.
http://openframeworks.cc
Other
9.84k stars 2.56k forks source link

ofAVFoundationVideoPlayer thread priority #7951

Closed dimitre closed 2 weeks ago

dimitre commented 1 month ago

Thread Performance Checker: Thread running at QOS_CLASS_USER_INTERACTIVE waiting on a lower QoS thread running at QOS_CLASS_DEFAULT. Investigate ways to avoid priority inversions PID: 27389, TID: 7269077

Backtrace
=================================================================
3   XP                                  0x00000001009976a8 -[ofAVFoundationVideoPlayer loadWithURL:async:] + 432
4   XP                                  0x0000000100a5a1d4 _ZN20ofAVFoundationPlayer10loadPlayerENSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEEb + 612
5   XP                                  0x0000000100a5a58c _ZN20ofAVFoundationPlayer4loadENSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEE + 144
6   XP                                  0x000000010097ff84 _ZN13ofVideoPlayer4loadENSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEE + 420
7   XP                                  0x00000001006ee8dc _ZN10ofxMicroUI9videoList9updateValEv + 328
8   XP                                  0x00000001006f12cc _ZN10ofxMicroUI5radio3setERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE + 616
9   XP                                  0x00000001006e44a0 _ZN10ofxMicroUI4loadERKNSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEE + 1712
10  XP                                  0x00000001006e7334 _ZN10ofxMicroUI10loadPresetERKNSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEE + 732
11  XP                                  0x000000010070266c _ZNSt3__110__function6__funcINS_6__bindIM10ofxMicroUIFvNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEEJPS3_RKNS_12placeholders4__phILi1EEEEEENS7_ISI_EEFvS9_EEclEOS9_ + 72
12  XP                                  0x00000001006f12ac _ZN10ofxMicroUI5radio3setERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE + 584
13  XP                                  0x00000001006e44a0 _ZN10ofxMicroUI4loadERKNSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEE + 1712
14  XP                                  0x00000001007060d0 _ZN18ofxMicroUISoftware10afterSetUIEv + 912
15  XP                                  0x00000001007093ec _ZNSt3__110__function6__funcIZN7ofEventINS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEENS_15recursive_mutexEE13make_functionI18ofxMicroUISoftwareEENS_10shared_ptrIN2of4priv8FunctionIS8_S9_EEEEPT_MSJ_FvRS8_EiEUlPKvSL_E_NS6_ISQ_EEFbSP_SL_EEclEOSP_SL_ + 40
16  XP                                  0x00000001006e90c0 _ZN7ofEventINSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEENS0_15recursive_mutexEE6notifyEPKvRS6_ + 160
17  XP                                  0x00000001006e4f2c _ZN10ofxMicroUI6notifyENSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEE + 44
18  XP                                  0x00000001006e3954 _ZN10ofxMicroUI7onSetupER11ofEventArgs + 52
19  XP                                  0x00000001006eb5ec _ZNSt3__110__function6__funcIZN7ofEventI11ofEventArgsNS_15recursive_mutexEE13make_functionI10ofxMicroUIEENS_10shared_ptrIN2of4priv8FunctionIS3_S4_EEEEPT_MSE_FvRS3_EiEUlPKvSG_E_NS_9allocatorISL_EEFbSK_SG_EEclEOSK_SG_ + 40
20  XP                                  0x00000001009851ac _ZN7ofEventI11ofEventArgsNSt3__115recursive_mutexEE6notifyEPKvRS0_ + 160
21  XP                                  0x0000000100698814 main + 512
22  dyld                                0x000000019aa47f28 start + 2236
dimitre commented 3 weeks ago

Latest XCode shows better the potential error. Message is:

Thread running at User-interactive quality-of-service class waiting on a lower QoS thread running at Default quality-of-service class. Investigate ways to avoid priority inversions

Any ideas of how to correct this for video player? cc @danoli3 @2bbb @danomatika

Screenshot 2024-06-13 at 11 43 01
2bbb commented 3 weeks ago

sorry, I don't have newer envs of mac. but can you try to replace line like below?

queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); with queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0);

https://github.com/openframeworks/openFrameworks/blob/dee2eb7044aa37053d0b473c195bd6abecd786bc/libs/openFrameworks/video/ofAVFoundationVideoPlayer.m#L173C37-L173C68

dimitre commented 3 weeks ago

This fixes the warning here! thank you. Should I submit a PR?

2bbb commented 3 weeks ago

great!

NickHardeman commented 2 weeks ago

@dimitre can this issue be closed because #8018 was merged?

dimitre commented 2 weeks ago

Yes! closed by https://github.com/openframeworks/openFrameworks/pull/8018