非超时逻辑
WKContentViewInteraction.mm(地址:https://github.com/WebKit/WebKit/blob/releases/Apple/Safari-16.1-iOS-16.1.1/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm)
抠图识别成功后,具有 CopySubject 菜单。
因此新的方案为 Hook WKWebView 长按手势图片识别能力。

static void hook2(void) { Class class = objc_getClass("WKContentView"); SEL selector = sel_registerName("imageAnalysisGestureDidBegin:"); Method m = class_getInstanceMethod(class, selector); const char type = method_getTypeEncoding(m); IMP newImp = imp_implementationWithBlock(^void(id self,UILongPressGestureRecognizer ges) { // do nothing }); if (m == NULL || class == NULL) { return; } IMP oldImp = class_replaceMethod(class, selector, newImp, type);}void hookStart() { if (@available (iOS 16.0, )) { if (@available (iOS 16.2, )) { return; } else { hook2(); } }}
由于 Hook 长按手势后会导致 WKWebview 自带的抠图功能和笔墨 OCR 功能失落效,担心有舆情风险。我们选择在手机淘宝安全气垫 SDK 实现此 Hook,并且通过放量修复。我们在 10.28.11 中通过放量来进行不雅观察,创造Crash 从 500+ 跌倒了 67 (冷起生效,有时效性问题),可以确认修复有效,并且没有舆情反馈。全量后,经由不雅观察,带有 Hook 方案的手机淘宝 Crash 基本跌 0,至此此 Bug 彻底修复。 日降落 Crash 1200+,影响设备 1000+ 。
总结
稳定性管理是一个长期的事情,由于前期同事的努力使得用户Crash 基本办理,一些操作系统的 Bug 逐步浮出水面,冲上排行榜,起初我并没有信心办理系统的 Bug,但是在定位过程中利用自己学习到的知识抽丝剥茧逐步定位到问题,也让自己对系统 Crash 不在畏惧,同时感谢同事在排查Bug 期间的履历输出和辅导。
同时在定位过程中如有疑问或缺点,欢迎谈论、示正。
参考资料
1. iOS app crashed on iOS 16 https://developer.apple.com/forums/thread/7183052. The-ABI-for-ARM-64-bit-Architecture https://developer.arm.com/documentation/den0024/a/The-ABI-for-ARM-64-bit-Architecture/Register-use-in-the-AArch64-Procedure-Call-Standard/Parameters-in-general-purpose-registers3. WebKit https://github.com/WebKit/WebKit
作者:倾寒
来源:微信"大众号:大淘宝技能
出处:https://mp.weixin.***.com/s/pmnrDbIeueGS_7Sck-83***