Thumbnail preview extension crashing when loading WKWebView

Developing a thumbnail extension for a custom file type in my iOS app. I am using a WKWebView to render an HTML string and then capturing a snapshot of the WKWebView to use for the thumbnail image. Works great on simulators. However, not completing when run on a real device.

Here is the code:
Code Block
let thumbFileView = WKWebView(frame: frame)
thumbFileView.navigationDelegate = self
thumbFileView.pageZoom = scale
thumbFileView.layoutIfNeeded()
thumbFileView.loadHTMLString(thumbFile.asHtml, baseURL: nil)

Thumbnail image is perfect on simulator, but on real device there is a crash in the logs:

Code Block
2020-12-08 11:01:30.191156-0700 ThumbFileThumbnail[35519:906998] [] networkd_settings_setup_notify_watch notify_register_dispatch(com.apple.system.networkd.settings) [status 9] failed
2020-12-08 11:01:30.205445-0700 ThumbFileThumbnail[35519:906998] [] networkd_settings_setup_notify_watch notify_register_dispatch(com.apple.system.networkd.settings) [status 9] failed, dumping backtrace:
[arm64] libnetcore-2288.42.1
0 libnetwork.dylib 0x00000001a2ce1658 __nw_create_backtrace_string + 116
1 libnetwork.dylib 0x00000001a2c6ffdc C67A2D71-4415-3F82-9399-65C3956520AE + 5832668
2 libnetwork.dylib 0x00000001a2c6f6c0 C67A2D71-4415-3F82-9399-65C3956520AE + 5830336
3 libnetwork.dylib 0x00000001a2a777d0 C67A2D71-4415-3F82-9399-65C3956520AE + 3766224
4 libnetwork.dylib 0x00000001a2c26408 nw_path_create_evaluator_for_endpoint_no_evaluate + 544
5 libnetwork.dylib 0x00000001a2c25ee0 nw_path_create_evaluator_for_endpoint + 84
6 Network 0x00000001b5a063e0 2FB89D76-EA38-3B43-BCD1-E0C7EE9B9012 + 1180640
7 Network 0x00000001b5a058b4 2FB89D76-EA38-3B43-BCD1-E0C7EE9B9012 + 1177780
8 libdispatch.dylib 0x00000001a18c0280 6C143C51-288F-3CD0-84DD-17B9A0AAEE62 + 397952
9 libdispatch.dylib 0x00000001a18642f4 6C143C51-288F-3CD0-84DD-17B9A0AAEE62 + 21236
10 Network 0x00000001b5a05888 2FB89D76-EA38-3B43-BCD1-E0C7EE9B9012 + 1177736
11 NetworkExtension 0x00000001b268a4e4 4F673F38-E238-37C5-9B26-2A540CB429B9 + 357604
12 WebKit 0x00000001ad9a8334 19789FD9-1098-37B7-B639-9E4F0EB867D6 + 2847540
13 WebKit 0x00000001ada0bdc8 19789FD9-1098-37B7-B639-9E4F0EB867D6 + 3255752
14 WebKit 0x00000001ada0ba20 19789FD9-1098-37B7-B639-9E4F0EB867D6 + 3254816
15 WebKit 0x00000001ad6fda9c 19789FD9-1098-37B7-B639-9E4F0EB867D6 + 51868
16 ThumbFileThumbnail 0x00000001044f4ee8 $s18ThumbFileThumbnail0abC9GeneratorC04loadaB4View3for2in5scaleSo05WKWebF0CAA0aB0V_So6CGRectV12CoreGraphics7CGFloatVtF + 704
17 ThumbFileThumbnail 0x00000001044f42a4 $s18ThumbFileThumbnail0abC9GeneratorC20provideSnapshotImage3for5scale5frame10completionyAA0aB0V_12CoreGraphics7CGFloatVSo6CGRectVySo7UIImageCSgctFyycfU_ + 204


From setting a runtime issues breakpoint, the offending line of code is:
Code Block
thumbFileView.loadHTMLString(thumbFile.asHtml, baseURL: nil)

Since the html contains an image URL, this seems to point to some limitation that iOS is placing on the thumbnail extension that is blocking it from accessing the network. This is evident from the crash log and from the stack at the time of the issue.
I've studied Apple's documentation of NSExtensionAttributes and can't find anything that would address this permission issue.
Here are the NSExtensionAttributes for the thumbnail extension:

Code Block
<key>NSExtension</key>
<dict>
<key>NSExtensionAttributes</key>
<dict>
<key>QLSupportedContentTypes</key>
<array>
<string>com.raywenderlich.RazeThumb.ThumbFile</string>
</array>
<key>QLThumbnailMinimumDimension</key>
<integer>0</integer>
</dict>


Why is this crashing on a real device but not on a simulator?
Thumbnail preview extension crashing when loading WKWebView
 
 
Q