Hi everyone and thanks for your time.
Intro
I'm developing an iOS app that has Content Blockers as one of its features. For this, we have a list of predefined rules the user can enable/disable at will, and also an option to enter custom rules.
Whenever there's a change (enable, disable, add or remove), I get all the rules and recreate the JSON files, one file for every 150K rules (we have more than one content blocker). Most users just need one JSON file though. And then call the content blockers reload.
The Problem
Most of the time, it works well. The content blocker reloads and I can verify in Safari that it's working.
But, sometimes within the completionHandler of:
SFContentBlockerManager.reloadContentBlocker(withIdentifier:completionHandler:)
It returns the following error:
Error Domain=NSCocoaErrorDomain Code=4097 "connection to service named com.apple.SafariServices.ContentBlockerLoader" UserInfo={NSDebugDescription=connection to service named com.apple.SafariServices.ContentBlockerLoader}
Localized description: Couldn’t communicate with a helper application.
Can't find a reason why this is happening. Some previous research said this could be related to:
- App groups, but I verified them and they are correctly set (even because the blockers reload works most of the time);
- Content blocker process being killed. But why would it be killed just sometimes? And how to I verify if this is the case?
I'm seeing a number of these errors (added a log) in production.
Thanks for the help.