Skip to content

iOS 11 - Main Thread Checker: UI API called on a background thread: -[UIView layer]  #143

Description

@codegastudio

Hi,

With Xcode 9 and device with iOS 11
When i activate blur i get the following message in logger

Main Thread Checker: UI API called on a background thread: -[UIView layer]
PID: 2255, TID: 1737593, Thread name: (none), Queue name: com.apple.root.default-qos, QoS: 21
Backtrace:
4 MyApp 0x00000001004a9b94 -[FXBlurView blurLayer] + 40
5 MyApp 0x00000001004a976c -[FXBlurView blurRadius] + 40
6 MyApp 0x00000001004abb8c __46-[FXBlurView updateAsynchronously:completion:]_block_invoke + 68
7 libdispatch.dylib 0x000000010082149c _dispatch_call_block_and_release + 24
8 libdispatch.dylib 0x000000010082145c _dispatch_client_callout + 16
9 libdispatch.dylib 0x000000010082d56c _dispatch_queue_override_invoke + 980
10 libdispatch.dylib 0x0000000100832b54 _dispatch_root_queue_drain + 616
11 libdispatch.dylib 0x0000000100832880 _dispatch_worker_thread3 + 136
12 libsystem_pthread.dylib 0x0000000182c5f130 _pthread_wqthread + 1268
13 libsystem_pthread.dylib 0x0000000182c5ec30 start_wqthread + 4

- (void)updateAsynchronously:(BOOL)async completion:(void (^)())completion
{
    if ([self shouldUpdate])
    {
        UIImage *snapshot = [self snapshotOfUnderlyingView];
        if (async)
        {
            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{

                UIImage *blurredImage = [self blurredSnapshot:snapshot radius:self.blurRadius];
                dispatch_sync(dispatch_get_main_queue(), ^{

                    [self setLayerContents:blurredImage];
                    if (completion) completion();
                });
            });
        }
        else
        {
            [self setLayerContents:[self blurredSnapshot:snapshot radius:[self blurPresentationLayer].blurRadius]];
            if (completion) completion();
        }
    }
    else if (completion)
    {
        completion();
    }
}

Possible to try with

...
dispatch_async(dispatch_get_main_queue(), ^{
        ...
});
...

Best regards,

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions