facebookincubator / SocketRocket

A conforming Objective-C WebSocket client library.
Other
9.54k stars 2.01k forks source link

SRWebSocket.m give Hang risk warning in Xcode 14 #661

Open maheshshahu opened 1 year ago

maheshshahu commented 1 year ago
- (NSRunLoop *)runLoop;
{
    dispatch_group_wait(_waitGroup, DISPATCH_TIME_FOREVER);
    return _runLoop;
}

error:- Thread running at QOS_CLASS_USER_INITIATED waiting on a lower QoS thread running at QOS_CLASS_DEFAULT. Investigate ways to avoid priority inversions

Screenshot 2023-05-04 at 2 34 12 PM
danipralea commented 1 year ago

I have the same issue

wuyeAn commented 1 year ago

I have the same issue

anandyadav19901990 commented 1 year ago

adding qualityOfService to networkThread object solved the problem.

Screenshot 2023-05-16 at 4 19 06 PM
funnel20 commented 1 year ago

Here is the solution from @anandyadav19901990 in plain text, as macOS derives zeros from the upper case "O" in the original image:

+ (NSRunLoop *)SR_networkRunLoop {
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        networkThread = [[_SRRunLoopThread alloc] init];
        networkThread.name = @"com.squareup.SocketRocket.NetworkThread";
        networkThread.qualityOfService = NSQualityOfServiceUserInitiated;
        [networkThread start];
        networkRunLoop = networkThread.runLoop;
    });

    return networkRunLoop;
}

The new line is:

networkThread.qualityOfService = NSQualityOfServiceUserInitiated;
funnel20 commented 4 months ago

Note that the above solution applies to versions prior to 0.7.0, as it has been resolved in version 0.7.0: https://github.com/facebookincubator/SocketRocket/commit/7240f2d25ef0b5cae2aba85dd4822b6188eb79c9

Please close this issue and mark as resolved.