ios - 更新 contentOffset 时崩溃
问题描述
let bottomOffset = bottomView.contentOffset.y
let currentOffset = overlayScrollView?.contentOffset.y ?? CGFloat(0)
let totalOffset = (bottomOffset + currentOffset) > 0 ? (bottomOffset + currentOffset) : 0
bottomView.contentOffset.y = 0
overlayScrollView?.contentOffset.y = totalOffset
我在这条线上的应用程序中遇到了几次 EXC_BAD_ACCESS KERN_PROTECTION_FAILURE 类型的崩溃
overlayScrollView?.contentOffset.y = totalOffset
最初,我认为这是因为 KVO 没有被正确处理,这可能是消息被发送到释放的对象并且观察者没有被删除。移至新的 KVO keyPathBased API,消除了删除观察者的开销。但是这个问题仍然在发生。这个问题在我身上根本无法重现。
0 QuartzCore 0x1a42bb938 CA::Layer::writable_state(CA::Transaction*) + 490
1 QuartzCore 0x1a42bba74 CA::Layer::end_change(CA::Transaction*, unsigned int, objc_object*, objc_object*) + 32
2 QuartzCore 0x1a42c4a04 CA::Layer::set_position(CA::Vec2<double> const&, bool) + 312
3 QuartzCore 0x1a42b2dbc -[CALayer setPosition:] + 48
4 QuartzCore 0x1a42b3450 -[CALayer setFrame:] + 424
5 UIKitCore 0x1a3e28df0 -[UIView(Geometry) setFrame:] + 472
6 UIKitCore 0x1a3dcf4b4 -[UIScrollView _layoutHorizontalScrollIndicatorWithBounds:effectiveInset:contentOffset:fraction:additionalInset:cornerAdjust:showing:recalcSize:verticalIndicatorFrame:] + 1320
7 UIKitCore 0x1a3dce89c -[UIScrollView _adjustScrollerIndicators:alwaysShowingThem:] + 1288
8 UIKitCore 0x1a3dbabfc -[UIScrollView setContentOffset:] + 1208
9 UIKitCore 0x1a3b46ed4 -[UITableView setContentOffset:] + 284
10 Foundation 0x1a236dbd8 -[NSObject(NSKeyValueObservingPrivate) _changeValueForKeys:count:maybeOldValuesDict:maybeNewValuesDict:usingBlock:] + 560
11 Foundation 0x1a22b2600 -[NSObject(NSKeyValueObservingPrivate) _changeValueForKey:key:key:usingBlock:] + 68
12 Foundation 0x1a2369614 _NSSetPointValueAndNotify + 300
13 App 0x10488393c partial apply for closure #2 in PageBaseViewController.updatePanView(view:index:) + 540 (PageBaseViewController.swift:540)
14 App 0x1048822d8 partial apply for thunk for @escaping @callee_guaranteed (@guaranteed ZScrollView, @in_guaranteed NSKeyValueObservedChange<CGPoint>) -> () + 4369375960 (<compiler-generated>:4369375960)
15 libswiftFoundation.dylib 0x1a48d6a50 closure #1 in _KeyValueCodingAndObserving.observe<A>(_:options:changeHandler:) + 320
16 libswiftFoundation.dylib 0x1a48d9cc4 specialized NSKeyValueObservation.Helper._swizzle_me_observeValue(forKeyPath:of:change:context:) + 1268
17 libswiftFoundation.dylib 0x1a48d6494 @objc NSKeyValueObservation.Helper._swizzle_me_observeValue(forKeyPath:of:change:context:) + 192
18 Foundation 0x1a236bd70 NSKeyValueNotifyObserver + 288
19 Foundation 0x1a236e188 NSKeyValueDidChange + 324
20 Foundation 0x1a236dc14 -[NSObject(NSKeyValueObservingPrivate) _changeValueForKeys:count:maybeOldValuesDict:maybeNewValuesDict:usingBlock:] + 620
21 Foundation 0x1a22b2600 -[NSObject(NSKeyValueObservingPrivate) _changeValueForKey:key:key:usingBlock:] + 68
22 Foundation 0x1a2369614 _NSSetPointValueAndNotify + 300
23 UIKitCore 0x1a3b386b0 -[UITableView _restoreOrAdjustContentOffsetWithRowCount:initialContentInsetTop:] + 352
24 UIKitCore 0x1a3b27a50 -[UITableView _updateVisibleCellsNow:] + 3552
25 UIKitCore 0x1a3b27a78 -[UITableView _updateVisibleCellsNow:] + 3592
26 UIKitCore 0x1a3b27a78 -[UITableView _updateVisibleCellsNow:] + 3592
27 UIKitCore 0x1a3b27a78 -[UITableView _updateVisibleCellsNow:] + 3592
28 UIKitCore 0x1a3b27a78 -[UITableView _updateVisibleCellsNow:] + 3592
29 UIKitCore 0x1a3b27a78 -[UITableView _updateVisibleCellsNow:] + 3592
30 UIKitCore 0x1a3b27a78 -[UITableView _updateVisibleCellsNow:] + 3592
31 UIKitCore 0x1a3b27a78 -[UITableView _updateVisibleCellsNow:] + 3592
32 UIKitCore 0x1a3b27a78 -[UITableView _updateVisibleCellsNow:] + 3592
33 UIKitCore 0x1a3b27a78 -[UITableView _updateVisibleCellsNow:] + 3592
34 UIKitCore 0x1a3b27a78 -[UITableView _updateVisibleCellsNow:] + 3592
35 UIKitCore 0x1a3b44938 -[UITableView layoutSubviews] + 356
36 UIKitCore 0x1a3e44910 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 2544
37 QuartzCore 0x1a42b96dc -[CALayer layoutSublayers] + 288
38 QuartzCore 0x1a42bfe64 CA::Layer::layout_if_needed(CA::Transaction*) + 544
39 QuartzCore 0x1a42cb424 CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 140
40 QuartzCore 0x1a4213c20 CA::Context::commit_transaction(CA::Transaction*, double, double*) + 500
41 QuartzCore 0x1a423e970 CA::Transaction::commit() + 668
42 UIKitCore 0x1a39752c0 _afterCACommitHandler + 140
43 CoreFoundation 0x1a102d418 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 32
44 CoreFoundation 0x1a1027a48 __CFRunLoopDoObservers + 588
45 CoreFoundation 0x1a1027fe4 __CFRunLoopRun + 1012
46 CoreFoundation 0x1a10276a8 CFRunLoopRunSpecific + 572
47 GraphicsServices 0x1b76d7570 GSEventRunModal + 160
48 UIKitCore 0x1a3945370 -[UIApplication _run] + 1052
49 UIKitCore 0x1a394a8ec UIApplicationMain + 164
50 App 0x10460b944 main + 15 (main.m:15)
51 libdyld.dylib 0x1a0d06140 start + 4
解决方案
推荐阅读
- javascript - 如何更改输入框中的特定字母颜色?
- robotframework - 如何一次运行多个机器人关键字以选择地理地图中的区域
- android - 在运行时更新 textview,同时为每个循环将图像上传到 firebase kotlin,而不冻结 ui
- c - 为什么 strcasecmp() 不返回 0 尽管它应该在 C 程序中正确区分大小写?
- node.js - CouchDB Mango 查询 - 将任何键与数组项匹配
- karate - 升级到 1.0.0 后,空手道摘要报告未显示所有测试功能
- xamarin - 轮播视图无法正确显示当前项目
- json - de 结构 json 嵌套对象
- ansible - Ansible 通过 ssh 同步
- c# - 如何在 UWP FullTrusted 应用程序中部署文件