gpt4 book ai didi

ios - 崩溃 viewDidMoveToWindow :shouldAppearOrDisappear: on iOS 10

转载 作者:行者123 更新时间:2023-12-03 21:31:03 27 4
gpt4 key购买 nike

一段时间以来,我的应用程序在生产中崩溃,但在 Debug模式下无法重现此错误。

Crashlytics 中的错误是:

UIKit
-[UIViewController viewDidMoveToWindow:shouldAppearOrDisappear:]

SIGABRT ABORT 0x00000001825d4d74

Crashed: com.apple.main-thread
0 libsystem_kernel.dylib 0x1825d4d74 __abort_with_payload + 8
1 libsystem_kernel.dylib 0x1825d1480 abort_with_payload_wrapper_internal + 100
2 libsystem_kernel.dylib 0x1825d141c abort_with_payload_wrapper_internal + 34
3 libobjc.A.dylib 0x18203fed8 _objc_fatalv(unsigned long long, unsigned long long, char const*, char*) + 112
4 libobjc.A.dylib 0x18203fe30 __objc_error + 42
5 libobjc.A.dylib 0x182052cd4 weak_entry_insert(weak_table_t*, weak_entry_t*) + 318
6 libobjc.A.dylib 0x182058664 objc_initWeak + 324
7 UIKit 0x1894ce1bc -[UIViewController viewDidMoveToWindow:shouldAppearOrDisappear:] + 2068
8 UIKit 0x18944db5c -[UIView(Internal) _didMoveFromWindow:toWindow:] + 1352
9 UIKit 0x18944d8e4 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 720
10 UIKit 0x189471714 -[UIScrollView _didMoveFromWindow:toWindow:] + 92
11 UIKit 0x18944d8e4 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 720
12 UIKit 0x18944d8e4 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 720
13 UIKit 0x189471714 -[UIScrollView _didMoveFromWindow:toWindow:] + 92
14 UIKit 0x18944d8e4 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 720
15 UIKit 0x18944d8e4 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 720
16 UIKit 0x18944d8e4 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 720
17 UIKit 0x18944d8e4 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 720
18 UIKit 0x18944d8e4 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 720
19 UIKit 0x18944d8e4 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 720
20 UIKit 0x18944d8e4 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 720
21 UIKit 0x18944d8e4 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 720
22 UIKit 0x18944cd90 __45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke + 156
23 Foundation 0x184034510 -[NSISEngine withBehaviors:performModifications:] + 168
24 UIKit 0x18944cc04 -[UIView(Hierarchy) _postMovedFromSuperview:] + 820
25 UIKit 0x18974a078 __UIViewWasRemovedFromSuperview + 172
26 UIKit 0x18944bc80 -[UIView(Hierarchy) removeFromSuperview] + 512
27 UIKit 0x1897a23dc __71-[UIPresentationController _initViewHierarchyForPresentationSuperview:]_block_invoke.629 + 1044
28 UIKit 0x18979c4fc -[UIPresentationController transitionDidFinish:] + 124
29 UIKit 0x18990afc8 -[_UICurrentContextPresentationController transitionDidFinish:] + 40
30 UIKit 0x1897a012c __56-[UIPresentationController runTransitionForCurrentState]_block_invoke_2 + 188
31 UIKit 0x189578ad4 -[_UIViewControllerTransitionContext completeTransition:] + 116
32 UIKit 0x1895788c0 -[UITransitionView notifyDidCompleteTransition:] + 252
33 UIKit 0x1895783dc -[UITransitionView _didCompleteTransition:] + 1240
34 UIKit 0x189577ef0 -[UITransitionView _transitionDidStop:finished:] + 124
35 UIKit 0x189489b48 -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 312
36 UIKit 0x189489988 -[UIViewAnimationState animationDidStop:finished:] + 160
37 QuartzCore 0x186912404 CA::Layer::run_animation_callbacks(void*) + 260
38 libdispatch.dylib 0x1824911c0 _dispatch_client_callout + 16
39 libdispatch.dylib 0x182495d6c _dispatch_main_queue_callback_4CF + 1000
40 CoreFoundation 0x1835b5f2c __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12
41 CoreFoundation 0x1835b3b18 __CFRunLoopRun + 1660
42 CoreFoundation 0x1834e2048 CFRunLoopRunSpecific + 444
43 GraphicsServices 0x184f65198 GSEventRunModal + 180
44 UIKit 0x1894bc628 -[UIApplication _run] + 684
45 UIKit 0x1894b7360 UIApplicationMain + 208
46 <App Name> 0x100081590 main (main.m:14)
47 libdispatch.dylib 0x1824c45b8 (Missing)

大多数日志显示用户有 1% 到 3% 的 RAM 内存可用,但也有一些超过 10%。

此外,我的应用程序使用 Sentry 跟踪错误,但此错误仅在 Fabric 中不在 Sentry 中。

我的大多数用户使用 iOS 10,但仍有一些用户使用 iOS 9,这次崩溃似乎不会影响这些用户。所以它似乎与iOS 10有关。

我也在这里搜索过,但我什至找不到解决方案的线索。有人可以帮我找到线索吗?

编辑

关于新代码引入的与 UIViewController 相关的注释是:
    - (IBAction)tapClose:(id)sender {
[self close];
}

- (void)close {
_dismissing = YES;

CGFloat height = self.view.superview.frame.size.height;
[UIView animateWithDuration:0.2 animations:^{
[self.view setFrame:CGRectMake(0, height, self.view.frame.size.width, self.view.frame.size.height)];
_overlay.alpha = 0;
} completion:^(BOOL finished) {
if (finished) {
[self.view removeFromSuperview];
[_overlay removeFromSuperview];
if (self.blockWhenClose) {
self.blockWhenClose();
}
}
}];
}

- (void)showIn:(UIViewController *)viewcontroller {
CGRect frame = viewcontroller.view.frame;
CGFloat height = [self calculateHeight:frame.size.height / 2];
[self.view setFrame:CGRectMake(0, frame.size.height, frame.size.width, height)];
[_overlay setFrame:frame];
_overlay.alpha = 0;
[viewcontroller addChildViewController:self];
[viewcontroller.view addSubview:_overlay];
[viewcontroller.view addSubview:self.view];
[self didMoveToParentViewController:viewcontroller];
[UIView animateWithDuration:_duration animations:^{
_overlay.alpha = 1;
[self.view setFrame:CGRectMake(0, frame.size.height - height, frame.size.width, height)];
}];
_show = YES;
}

但我不知道崩溃究竟发生在哪里。

最佳答案

对我来说,这是从 iOS 14 开始的
问题是,我在代码中将 Controller (A) 的 View 作为 subview 添加到另一个 Controller (B) 中,而不持有对 Controller (A) 本身的引用。 Controller (A)被释放,下次 View 即将出现或消失时,它会尝试通知导致崩溃的 Controller (A)。
解决方案:

  • 手动保存对 Controller 的引用
  • 或 addChildViewController 为您执行上述操作
  • 关于ios - 崩溃 viewDidMoveToWindow :shouldAppearOrDisappear: on iOS 10,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42269914/

    27 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com