Crash in Content Blocker Extension Due to Memory Limit on iOS 17 (17.0.3)
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 the memory limit for content rules in iOS 17 has been increased to 24MB.
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`.