Crash in Content Blocker Extension Due to Memory Limit on iOS 17

When using a content rules file prepared for Safari with a size of, for instance, 20MB, we encountered a crash on iOS 17. This is surprising given that just a few versions back Safari has increased the content rules limit to 150k. Now with this issue introduced, even when a content blocker is under the old 50k limit, we may not be able to register it.

Technical Details:

We use a class that implements the beginRequest(with context: NSExtensionContext) method from the NSExtensionRequestHandling protocol. For this implementation, we utilize NSItemProvider initialized with init(contentOf: URL), where the URL points to path/to/file.json.

The crash arises when invoking context.completeRequest(returningItems: [<object of NSItemProvider>], completionHandler: nil), with context being an instance of NSExtensionContext. Notably, using the same 20MB file and identical code, no such crash was observed on iOS 16.6.1 or iOS 12.5.7.

Steps to Reproduce:

In the host app, invoke SFContentBlockerManager.reloadContentBlocker(...). Within the beginRequest(with context: NSExtensionContext) method of the class implementing the NSExtensionRequestHandling protocol:Instantiate NSItemProvider(contentOf: <PATH/TO/FILE.json>) using a large-sized rule set (e.g., 20MB or more). Execute context.completeRequest(returningItems: [<object of NSItemProvider>], completionHandler: nil).

Note: The issue is specific to iOS 17. On other versions, no crash is observed.

Expected behavior:

The content blocker extension should operate without crashing.

Actual behavior:

The content blocker extension crashes.

Also, we have opened another ticket in Feedback Assistant, its ID: FB13282146.

UPD: We recently tested on iOS 17.1.1, and the issue still persists.

Are there any updates on this? I am experiencing the same issue on iOS 17.5.1

Crash in Content Blocker Extension Due to Memory Limit on iOS 17
 
 
Q