正在加载今日诗词....
1 min read

WKWebView CALayerInvalidGeometry

WKWebView CALayerInvalidGeometry

问题

  • WKWebView 加载 本地PDF
CoreFoundation	___exceptionPreprocess + 124
1 libobjc.A.dylib	objc_exception_throw + 56
2 CoreFoundation	-[NSException initWithCoder:]
3 QuartzCore	0x000000018cd9f000 + 1108684
4 QuartzCore	0x000000018cd9f000 + 1109064
5 QuartzCore	0x000000018cd9f000 + 1110424
6 UIKit	-[UIView(Geometry) setFrame:] + 792
7 WebKit	-[WKPDFView _computePageAndDocumentFrames] + 648
8 WebKit	-[WKPDFView _didLoadPDFDocument] + 104
9 WebKit	-[WKPDFView web_setContentProviderData:suggestedFilename:] + 164
10 WebKit	-[WKWebView _didFinishLoadingDataForCustomContentProviderWithSuggestedFilename:data:] + 84
11 WebKit	WebKit::PageClientImpl::didFinishLoadingDataForCustomContentProvider(WTF::String const&, IPC::DataReference const&) + 100
  • In my case it was triggered by trying to display a UIWebView that had been created from an NSData object with invalid data, possibly from an empty file

  • 测试: 加载本地0KBPDF文件并不会导致CALayerInvalidGeometry

解决

  • WKWebView 或者 UIWebview 初始化 一定要设置 frame

  • 设置Xcode CG_NUMERICS_SHOW_BACKTRACE环境变量 检测异常参数

  • 键盘的问题??

参考