diff --git a/Channel/Sources/EDOSocketChannel.m b/Channel/Sources/EDOSocketChannel.m index 8ddf9c4..ea0be10 100644 --- a/Channel/Sources/EDOSocketChannel.m +++ b/Channel/Sources/EDOSocketChannel.m @@ -67,9 +67,16 @@ - (instancetype)initWithHandlerQueue:(dispatch_queue_t)handlerQueue { if (self) { // For internal IO and event handlers, it is equivalent to creating it as a serial queue as they // are not reentrant and only one block will be scheduled by dispatch io and dispatch source. - _handlerQueue = - handlerQueue - ?: dispatch_queue_create("com.google.edo.socketChannel.handler", DISPATCH_QUEUE_SERIAL); + if (handlerQueue) { + _handlerQueue = handlerQueue; + } else { + // Use QOS_CLASS_USER_INITIATED as the default because eDO communication is often in the + // critical path of user-driven test execution, and using a lower QoS can lead to priority + // inversion issues. + dispatch_queue_attr_t attributes = dispatch_queue_attr_make_with_qos_class( + DISPATCH_QUEUE_SERIAL, QOS_CLASS_USER_INITIATED, 0); + _handlerQueue = dispatch_queue_create("com.google.edo.socketChannel.handler", attributes); + } } return self; } diff --git a/Service/Tests/FunctionalTests/EDOServiceUIBlockTest.m b/Service/Tests/FunctionalTests/EDOServiceUIBlockTest.m index de40fab..16de740 100644 --- a/Service/Tests/FunctionalTests/EDOServiceUIBlockTest.m +++ b/Service/Tests/FunctionalTests/EDOServiceUIBlockTest.m @@ -156,7 +156,7 @@ - (void)testBlockResolveToLocalAddress { // Sending block to remote process through background eDO host. dispatch_sync(backgroundQueue, ^{ - pthread_set_qos_class_self_np(QOS_CLASS_DEFAULT, 0); + pthread_set_qos_class_self_np(QOS_CLASS_USER_INITIATED, 0); remoteDummy.block = localBlock; }); diff --git a/Service/Tests/FunctionalTests/EDOServiceUITest.m b/Service/Tests/FunctionalTests/EDOServiceUITest.m index afafab4..ce1388b 100644 --- a/Service/Tests/FunctionalTests/EDOServiceUITest.m +++ b/Service/Tests/FunctionalTests/EDOServiceUITest.m @@ -226,7 +226,7 @@ - (void)testTemporaryServiceHandlesRecursiveCall { EDOTestDummy *remoteDummy = [EDOClientService rootObjectWithPort:EDOTEST_APP_SERVICE_PORT]; // Align QoS with eDO internal threads to avoid priority inversion. dispatch_queue_attr_t attr = - dispatch_queue_attr_make_with_qos_class(DISPATCH_QUEUE_SERIAL, QOS_CLASS_DEFAULT, 0); + dispatch_queue_attr_make_with_qos_class(DISPATCH_QUEUE_SERIAL, QOS_CLASS_USER_INITIATED, 0); dispatch_queue_t testQueue = dispatch_queue_create("com.google.edotest", attr); XCTestExpectation *expectation = [self expectationWithDescription:@"recursive call completes."];