英文:
How to fix a crash in SwiftUI caused by UICollectionView _validateScrollingTargetIndexPath?
问题
我正在开发一个SwiftUI应用程序。应用程序一直崩溃,并显示以下错误消息:
UIKitCore: - [UICollectionView _validateScrollingTargetIndexPath:] + 412
我已经在Xcode的Organizer > App > Reports > Crashes部分检查了崩溃日志,并发现这是问题的根源,但我不理解。
有人可以帮助我理解是什么导致了这个崩溃以及如何修复它吗?我会感激任何有关如何排除此问题的指导或建议。
提前感谢!
崩溃日志:
崩溃日志的内容(未翻译)
英文:
I'm working on a SwiftUI app. The app keeps crashing with the following error message:
UIKitCore: - [UICollectionView _validateScrollingTargetIndexPath:] + 412
I've checked the crash logs in Xcode's Organizer > App > Reports > Crashes section and found this to be the source of the problem, but I don't understand.
Can anyone help me understand what's causing this crash and how to fix it? I'd appreciate any guidance or advice on how to troubleshoot this issue.
Thanks in advance!
Crash Log:
Incident Identifier: B57CBB49-CE6A-4F79-AD15-C8A81B66A8AC
Hardware Model: iPhone12,1
Process: [APP_NAME] [42598]
Path: /private/var/containers/Bundle/Application/739BA0B9-3014-4384-AC60-6A96A30472F1/[APP_NAME].app/[APP_NAME]
Identifier: -- --
Version: 1.0.7 (2)
AppStoreTools: 14C17
Code Type: ARM-64 (Native)
Role: Foreground
Parent Process: launchd [1]
Coalition: -- -- [2646]
Date/Time: 2023-03-16 18:50:43.5696 +0300
Launch Time: 2023-03-16 18:45:21.3862 +0300
OS Version: iPhone OS 16.0.2 (20A380)
Release Type: User
Baseband Version: 4.00.00
Report Version: 104
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Triggered by Thread: 0
Last Exception Backtrace:
0 CoreFoundation 0x1c4d36248 __exceptionPreprocess + 164 (NSException.m:202)
1 libobjc.A.dylib 0x1be103a68 objc_exception_throw + 60 (objc-exception.mm:356)
2 Foundation 0x1bf6c281c -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 188 (NSException.m:242)
3 UIKitCore 0x1c72a6e80 -[UICollectionView _validateScrollingTargetIndexPath:] + 412 (UICollectionView.m:0)
4 UIKitCore 0x1c72a665c -[UICollectionView _contentOffsetForScrollingToItemAtIndexPath:atScrollPosition:] + 52 (UICollectionView.m:7348)
5 UIKitCore 0x1c72a6078 -[UICollectionView _scrollToItemAtIndexPath:atScrollPosition:animated:] + 240 (UICollectionView.m:7563)
6 SwiftUI 0x1c9045e38 PagingCollectionView.scrollToItem(at:at:animated:) + 320 (PageView_PhoneTV.swift:607)
7 SwiftUI 0x1c9045f24 @objc PagingCollectionView.scrollToItem(at:at:animated:) + 208 (<compiler-generated>:0)
8 SwiftUI 0x1c86b09dc PagingCollectionView.layoutSubviews() + 988 (PageView_PhoneTV.swift:595)
9 SwiftUI 0x1c86af9e8 @objc PagingCollectionView.layoutSubviews() + 36 (<compiler-generated>:0)
10 UIKitCore 0x1c6ebecec -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1980 (UIView.m:18550)
11 QuartzCore 0x1c639b4e8 CA::Layer::layout_if_needed(CA::Transaction*) + 500 (CALayer.mm:10223)
12 QuartzCore 0x1c63aeb9c CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 148 (CALayer.mm:2516)
13 QuartzCore 0x1c63c0098 CA::Context::commit_transaction(CA::Transaction*, double, double*) + 456 (CAContextInternal.mm:2711)
14 QuartzCore 0x1c63f73c4 CA::Transaction::commit() + 652 (CATransactionInternal.mm:431)
15 QuartzCore 0x1c63de408 CA::Transaction::flush_as_runloop_observer(bool) + 88 (CATransactionInternal.mm:939)
16 CoreFoundation 0x1c4dbe070 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 36 (CFRunLoop.c:1806)
17 CoreFoundation 0x1c4d46690 __CFRunLoopDoObservers + 532 (CFRunLoop.c:1919)
18 CoreFoundation 0x1c4da7f8c __CFRunLoopRun + 1048 (CFRunLoop.c:2998)
19 CoreFoundation 0x1c4dad1e4 CFRunLoopRunSpecific + 612 (CFRunLoop.c:3390)
20 GraphicsServices 0x1fdbcd368 GSEventRunModal + 164 (GSEvent.c:2196)
21 UIKitCore 0x1c725cd88 -[UIApplication _run] + 888 (UIApplication.m:3726)
22 UIKitCore 0x1c725c9ec UIApplicationMain + 340 (UIApplication.m:5316)
23 SwiftUI 0x1c885bce8 closure #1 in KitRendererCommon(_:) + 168 (UIKitApp.swift:37)
24 SwiftUI 0x1c87b8c24 runApp<A>(_:) + 152 (<compiler-generated>:0)
25 SwiftUI 0x1c87a1b44 static App.main() + 128 (App.swift:114)
26 [APP_NAME] 0x10418bb94 static [APP_NAME]App.$main() + 52 ([APP_NAME]App.swift:14)
27 [APP_NAME] 0x10418bb94 main + 64 (MainView.swift:0)
28 dyld 0x1e30d1948 start + 2504 (dyldMain.cpp:1168)
Kernel Triage:
VM - pmap_enter retried due to resource shortage
Thread 0 name:
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x000000020141e200 __pthread_kill + 8 (:-1)
1 libsystem_pthread.dylib 0x000000021165b1ac pthread_kill + 268 (pthread.c:1670)
2 libsystem_c.dylib 0x00000001cc26d3f4 __abort + 128 (abort.c:155)
3 libsystem_c.dylib 0x00000001cc215cac abort + 192 (abort.c:126)
4 libc++abi.dylib 0x000000021159db8c abort_message + 132 (abort_message.cpp:78)
5 libc++abi.dylib 0x000000021158da80 demangling_terminate_handler() + 336 (cxa_default_handlers.cpp:71)
6 libobjc.A.dylib 0x00000001be109eec _objc_terminate() + 144 (objc-exception.mm:498)
7 [APP_NAME] 0x000000010490cfd8 FIRCLSTerminateHandler() + 340 (FIRCLSException.mm:452)
8 libc++abi.dylib 0x000000021159cf28 std::__terminate(void (*)()) + 20 (cxa_handlers.cpp:59)
9 libc++abi.dylib 0x000000021159fecc __cxa_rethrow + 148 (cxa_exception.cpp:616)
10 libobjc.A.dylib 0x00000001be105854 objc_exception_rethrow + 44 (objc-exception.mm:401)
11 CoreFoundation 0x00000001c4dad2a8 CFRunLoopRunSpecific + 808 (CFRunLoop.c:3406)
12 GraphicsServices 0x00000001fdbcd368 GSEventRunModal + 164 (GSEvent.c:2196)
13 UIKitCore 0x00000001c725cd88 -[UIApplication _run] + 888 (UIApplication.m:3726)
14 UIKitCore 0x00000001c725c9ec UIApplicationMain + 340 (UIApplication.m:5316)
15 SwiftUI 0x00000001c885bce8 closure #1 in KitRendererCommon(_:) + 168 (UIKitApp.swift:37)
16 SwiftUI 0x00000001c87b8c24 runApp<A>(_:) + 152 (<compiler-generated>:0)
17 SwiftUI 0x00000001c87a1b44 static App.main() + 128 (App.swift:114)
18 [APP_NAME] 0x000000010418bb94 static [APP_NAME]App.$main() + 52 ([APP_NAME]App.swift:14)
19 [APP_NAME] 0x000000010418bb94 main + 64 (MainView.swift:0)
20 dyld 0x00000001e30d1948 start + 2504 (dyldMain.cpp:1168)
Thread 1 name:
Thread 1:
0 libsystem_kernel.dylib 0x0000000201419480 kevent + 8 (:-1)
1 [APP_NAME] 0x00000001044fdc84 realm::_impl::ExternalCommitHelper::listen() + 160 (external_commit_helper.cpp:219)
2 [APP_NAME] 0x00000001044fde64 realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&, realm::RealmConfig const&)::$_0::operator()() const + 4 (external_commit_helper.cpp:175)
3 [APP_NAME] 0x00000001044fde64 decltype(static_cast<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&, realm::RealmConfig const&)::$_0>(fp)()) std::__1::__invoke<realm::_impl::ExternalCommi... + 4 (type_traits:3918)
4 [APP_NAME] 0x00000001044fde64 void std::__1::__thread_execute<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm... + 4 (thread:287)
5 [APP_NAME] 0x00000001044fde64 void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, realm::_impl::ExternalCommitHelper::ExternalCom... + 52 (thread:298)
6 libsystem_pthread.dylib 0x00000002116556cc _pthread_start + 148 (pthread.c:893)
7 libsystem_pthread.dylib 0x0000000211654ba4 thread_start + 8 (:-1)
Thread 2 name:
Thread 2:
0 libsystem_kernel.dylib 0x0000000201417b48 mach_msg2_trap + 8 (:-1)
1 libsystem_kernel.dylib 0x000000020142a008 mach_msg2_internal + 80 (mach_msg.c:201)
2 libsystem_kernel.dylib 0x000000020142a248 mach_msg_overwrite + 388 (mach_msg.c:0)
3 libsystem_kernel.dylib 0x000000020141808c mach_msg + 24 (mach_msg.c:323)
4 [APP_NAME] 0x000000010490eb18 FIRCLSMachExceptionReadMessage + 60 (FIRCLSMachException.c:192)
5 [APP_NAME] 0x000000010490eb18 FIRCLSMachExceptionServer + 108 (FIRCLSMachException.c:168)
6 libsystem_pthread.dylib 0x00000002116556cc _pthread_start + 148 (pthread.c:893)
7 libsystem_pthread.dylib 0x0000000211654ba4 thread_start + 8 (:-1)
Thread 3 name:
Thread 3:
0 libsystem_kernel.dylib 0x0000000201417b48 mach_msg2_trap + 8 (:-1)
1 libsystem_kernel.dylib 0x000000020142a008 mach_msg2_internal + 80 (mach_msg.c:201)
2 libsystem_kernel.dylib 0x000000020142a248 mach_msg_overwrite + 388 (mach_msg.c:0)
3 libsystem_kernel.dylib 0x000000020141808c mach_msg + 24 (mach_msg.c:323)
4 CoreFoundation 0x00000001c4da6e00 __CFRunLoopServiceMachPort + 160 (CFRunLoop.c:2639)
5 CoreFoundation 0x00000001c4da8044 __CFRunLoopRun + 1232 (CFRunLoop.c:3022)
6 CoreFoundation 0x00000001c4dad1e4 CFRunLoopRunSpecific + 612 (CFRunLoop.c:3390)
7 Foundation 0x00000001bf1bd818 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 212 (NSRunLoop.m:373)
8 Foundation 0x00000001bf1bd700 -[NSRunLoop(NSRunLoop) runUntilDate:] + 64 (NSRunLoop.m:420)
9 UIKitCore 0x00000001c739188c -[UIEventFetcher threadMain] + 436 (UIEventFetcher.m:1212)
10 Foundation 0x00000001bf1d6ce8 __NSThread__start__ + 716 (NSThread.m:968)
11 libsystem_pthread.dylib 0x00000002116556cc _pthread_start + 148 (pthread.c:893)
12 libsystem_pthread.dylib 0x0000000211654ba4 thread_start + 8 (:-1)
Thread 4 name:
Thread 4:
0 libsystem_kernel.dylib 0x000000020141841c __psynch_cvwait + 8 (:-1)
1 libsystem_pthread.dylib 0x000000021165c06c _pthread_cond_wait + 1232 (pthread_cond.c:636)
2 JavaScriptCore 0x00000001d811fc70 scavenger_thread_main + 1364 (pas_scavenger.c:145)
3 libsystem_pthread.dylib 0x00000002116556cc _pthread_start + 148 (pthread.c:893)
4 libsystem_pthread.dylib 0x0000000211654ba4 thread_start + 8 (:-1)
Thread 5 name:
Thread 5:
0 libsystem_kernel.dylib 0x0000000201417b48 mach_msg2_trap + 8 (:-1)
1 libsystem_kernel.dylib 0x000000020142a008 mach_msg2_internal + 80 (mach_msg.c:201)
2 libsystem_kernel.dylib 0x000000020142a248 mach_msg_overwrite + 388 (mach_msg.c:0)
3 libsystem_kernel.dylib 0x000000020141808c mach_msg + 24 (mach_msg.c:323)
4 CoreFoundation 0x00000001c4da6e00 __CFRunLoopServiceMachPort + 160 (CFRunLoop.c:2639)
5 CoreFoundation 0x00000001c4da8044 __CFRunLoopRun + 1232 (CFRunLoop.c:3022)
6 CoreFoundation 0x00000001c4dad1e4 CFRunLoopRunSpecific + 612 (CFRunLoop.c:3390)
7 CFNetwork 0x00000001c60fbbac +[__CFN_CoreSchedulingSetRunnable _run:] + 392 (CoreSchedulingSet.mm:1372)
8 Foundation 0x00000001bf1d6ce8 __NSThread__start__ + 716 (NSThread.m:968)
9 libsystem_pthread.dylib 0x00000002116556cc _pthread_start + 148 (pthread.c:893)
10 libsystem_pthread.dylib 0x0000000211654ba4 thread_start + 8 (:-1)
Thread 6:
0 libsystem_pthread.dylib 0x0000000211654b90 _pthread_cond_updateval + 256 (pthread_cond.c:992)
Thread 7:
0 libsystem_pthread.dylib 0x0000000211654b90 _pthread_cond_updateval + 256 (pthread_cond.c:992)
Thread 8:
0 libsystem_pthread.dylib 0x0000000211654b90 _pthread_cond_updateval + 256 (pthread_cond.c:992)
Thread 9:
0 libsystem_pthread.dylib 0x0000000211654b90 _pthread_cond_updateval + 256 (pthread_cond.c:992)
Thread 10:
0 libsystem_pthread.dylib 0x0000000211654b90 _pthread_cond_updateval + 256 (pthread_cond.c:992)
Thread 11 name:
Thread 11:
0 libsystem_kernel.dylib 0x0000000201417b48 mach_msg2_trap + 8 (:-1)
1 libsystem_kernel.dylib 0x000000020142a008 mach_msg2_internal + 80 (mach_msg.c:201)
2 libsystem_kernel.dylib 0x000000020142a248 mach_msg_overwrite + 388 (mach_msg.c:0)
3 libsystem_kernel.dylib 0x000000020141808c mach_msg + 24 (mach_msg.c:323)
4 CoreFoundation 0x00000001c4da6e00 __CFRunLoopServiceMachPort + 160 (CFRunLoop.c:2639)
5 CoreFoundation 0x00000001c4da8044 __CFRunLoopRun + 1232 (CFRunLoop.c:3022)
6 CoreFoundation 0x00000001c4dad1e4 CFRunLoopRunSpecific + 612 (CFRunLoop.c:3390)
7 Foundation 0x00000001bf1bd818 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 212 (NSRunLoop.m:373)
8 Foundation 0x00000001bf1bd6ac -[NSRunLoop(NSRunLoop) run] + 64 (NSRunLoop.m:398)
9 SwiftUI 0x00000001c872e558 static DisplayLink.asyncThread(arg:) + 800 (_UIHostingView.swift:965)
10 SwiftUI 0x00000001c872c69c @objc static DisplayLink.asyncThread(arg:) + 88 (<compiler-generated>:0)
11 Foundation 0x00000001bf1d6ce8 __NSThread__start__ + 716 (NSThread.m:968)
12 libsystem_pthread.dylib 0x00000002116556cc _pthread_start + 148 (pthread.c:893)
13 libsystem_pthread.dylib 0x0000000211654ba4 thread_start + 8 (:-1)
Thread 0 crashed with ARM Thread State (64-bit):
x0: 0x0000000000000000 x1: 0x0000000000000000 x2: 0x0000000000000000 x3: 0x0000000000000000
x4: 0x0000000000000000 x5: 0x0000000000989680 x6: 0x000000000000006e x7: 0x0000000000000000
x8: 0x2d9f778a7e9debb1 x9: 0x2d9f7788646d0831 x10: 0x00000000000003e8 x11: 0x000000000000000b
x12: 0x000000000000000b x13: 0x0000000000000000 x14: 0x0000000000000000 x15: 0x0000000000000000
x16: 0x0000000000000148 x17: 0x000000021af0e380 x18: 0x0000000000000000 x19: 0x0000000000000006
x20: 0x0000000000000103 x21: 0x000000021af0e460 x22: 0x0000000000000007 x23: 0x0000000104cdc8c8
x24: 0x0000000000000000 x25: 0x0000000000000001 x26: 0x0000000000000001 x27: 0x0000000000000000
x28: 0x00000001e59479e0 fp: 0x000000016bc7eed0 lr: 0x000000021165b1ac
sp: 0x000000016bc7eeb0 pc: 0x000000020141e200 cpsr: 0x40000000
esr: 0x56000080 Address size fault
Binary Images:
0x104180000 - 0x104e33fff [APP_NAME] arm64 <09be88e72ed73d15b5ead893c272fde9> /private/var/containers/Bundle/Application/739BA0B9-3014-4384-AC60-6A96A30472F1/[APP_NAME].app/[APP_NAME]
0x1be0ec000 - 0x1be12fc3f libobjc.A.dylib arm64e <b3a78098c0fb3dcdb1ac0712762510db> /usr/lib/libobjc.A.dylib
0x1bf17c000 - 0x1bfac6fff Foundation arm64e <aa92cd58561a341492f4b4120298b39a> /System/Library/Frameworks/Foundation.framework/Foundation
0x1c4d2c000 - 0x1c5110fff CoreFoundation arm64e <42c5c91704473995b50fde4d132c2435> /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
0x1c5ea7000 - 0x1c626cfff CFNetwork arm64e <35605de33723335a83d96f35f2989935> /System/Library/Frameworks/CFNetwork.framework/CFNetwork
0x1c6391000 - 0x1c66e9fff QuartzCore arm64e <c4c4667b69333b01a37b747cd0c00431> /System/Library/Frameworks/QuartzCore.framework/QuartzCore
0x1c6eba000 - 0x1c8680fff UIKitCore arm64e <7b942fa4cb7633759972f58c14492fb4> /System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore
0x1c8681000 - 0x1c9ec9fff SwiftUI arm64e <122e646e6b173561975fc414c8dae3d3> /System/Library/Frameworks/SwiftUI.framework/SwiftUI
0x1cc1f5000 - 0x1cc274fff libsystem_c.dylib arm64e <82c0f938e2773165a61470151c651798> /usr/lib/system/libsystem_c.dylib
0x1d802c000 - 0x1d9503fff JavaScriptCore arm64e <9f4a8d8984473fa5a2e388d3c7ba1684> /System/Library/Frameworks/JavaScriptCore.framework/JavaScriptCore
0x1e30bc000 - 0x1e313ee4f dyld arm64e <341bbf646034357e8aa6e1e4b988e03c> /usr/lib/dyld
0x1fdbcc000 - 0x1fdbd4fff GraphicsServices arm64e <03732ba5113235b4b09d8dd49807d246> /System/Library/PrivateFrameworks/GraphicsServices.framework/GraphicsServices
0x201417000 - 0x20144dffb libsystem_kernel.dylib arm64e <a5d3b72578c33e19a765cceb22355093> /usr/lib/system/libsystem_kernel.dylib
0x21158c000 - 0x2115a3ffb libc++abi.dylib arm64e <e0dbf9459cc5305db096abc1cda9c8ca> /usr/lib/libc++abi.dylib
0x211654000 - 0x21165ffff libsystem_pthread.dylib arm64e <b89b9a5b55d93e84b6d3c3da93c1cd39> /usr/lib/system/libsystem_pthread.dylib
EOF
```
</details>
# 答案1
**得分**: 1
it seems iOS 16.0 bug. try update OS.
[Simple TabView is crashing in iOS 16](https://stackoverflow.com/questions/73950003/simple-tabview-is-crashing-in-ios-16)
<details>
<summary>英文:</summary>
it seems iOS 16.0 bug. try update OS.
[Simple TabView is crashing in iOS 16][1]
[1]: https://stackoverflow.com/questions/73950003/simple-tabview-is-crashing-in-ios-16
</details>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论