iOS项目中uni-app小程序sdk点击浏览大图崩溃
iOS项目中uni-app小程序sdk点击浏览大图崩溃
产品分类:uni小程序SDK
手机系统:iOS
手机系统版本号:iOS 18
手机厂商:苹果
手机机型:iPhone13
页面类型:vue
SDK版本号:4.87
操作步骤:
小程序中点击浏览图片大图,然后崩溃报错
预期结果:
浏览大图成功
实际结果:
app崩溃
bug描述:
iOS项目中集成uni小程序SDK,小程序中点击浏览大图崩溃,以下是崩溃信息:
uni小程序中打开浏览照片后app崩溃:
5+Runtime Crash##------
name:NSInvalidArgumentException
reason:
*** -[NSPlaceholderString initWithString:]: nil argument
callStackSymbols:
0 CoreFoundation 0x000000019cefe684 5A6C1F41-BF70-32F6-A1D6-5B894DD21362 + 968324
1 libobjc.A.dylib 0x00000001951a7c80 objc_exception_throw + 60
2 Foundation 0x000000019be4307c 5623831D-5719-33A9-9691-759F47D714D1 + 618620
3 HxflPortalIOS.debug.dylib 0x0000000109bcd434 -[DCSliderImageImageItem setContentImageStyle:index:] + 152
4 HxflPortalIOS.debug.dylib 0x0000000109cca358 -[PGNativeImageSliderView showImageView:AtIndex:] + 116
5 UIKitCore 0x000000019f071c04 2D538446-6E40-3C10-8A5F-559C938077A0 + 207876
6 QuartzCore 0x000000019e4847ec 5C3EE3D9-1AAA-3052-A6C7-B957B454AD71 + 419820
7 QuartzCore 0x000000019e484374 5C3EE3D9-1AAA-3052-A6C7-B957B454AD71 + 418676
8 QuartzCore 0x000000019e48a860 5C3EE3D9-1AAA-3052-A6C7-B957B454AD71 + 444512
9 QuartzCore 0x000000019e483b80 5C3EE3D9-1AAA-3052-A6C7-B957B454AD71 + 416640
10 QuartzCore 0x000000019e483828 5C3EE3D9-1AAA-3052-A6C7-B957B454AD71 + 415784
11 UIKitCore 0x000000019f0e9f34 2D538446-6E40-3C10-8A5F-559C938077A0 + 700212
12 UIKitCore 0x000000019f0e9a4c 2D538446-6E40-3C10-8A5F-559C938077A0 + 698956
13 UIKitCore 0x000000019f0e913c 2D538446-6E40-3C10-8A5F-559C938077A0 + 696636
14 UIKitCore 0x000000019f0e91f8 2D538446-6E40-3C10-8A5F-559C938077A0 + 696824
15 CoreFoundation 0x000000019ce490ac 5A6C1F41-BF70-32F6-A1D6-5B894DD21362 + 225452
16 CoreFoundation 0x000000019ce48328 5A6C1F41-BF70-32F6-A1D6-5B894DD21362 + 221992
17 CoreFoundation 0x000000019ce46adc 5A6C1F41-BF70-32F6-A1D6-5B894DD21362 + 215772
18 CoreFoundation 0x000000019ce45818 5A6C1F41-BF70-32F6-A1D6-5B894DD21362 + 210968
19 CoreFoundation 0x000000019ce453f8 CFRunLoopRunSpecific + 608
20 GraphicsServices 0x00000001e03fb4f8 GSEventRunModal + 164
21 UIKitCore 0x000000019f26b8a0 2D538446-6E40-3C10-8A5F-559C938077A0 + 2279584
22 UIKitCore 0x000000019f26aedc UIApplicationMain + 340
23 SwiftUI 0x00000001a1c7c898 2607F991-9547-3A50-A7E3-C0C3A09741E8 + 18245784
24 SwiftUI 0x00000001a1c7c6dc 2607F991-9547-3A50-A7E3-C0C3A09741E8 + 18245340
25 SwiftUI 0x00000001a18ed25c 2607F991-9547-3A50-A7E3-C0C3A09741E8 + 14512732
26 HxflPortalIOS.debug.dylib 0x0000000109591558 $s13HxflPortalIOS0aB6IOSAppV5$mainyyFZ + 40
27 HxflPortalIOS.debug.dylib 0x00000001095917c4 __debug_main_executable_dylib_entry_point + 12
28 dyld 0x00000001bfbaedcc 28D6D2C1-46CE-3D58-B744-B06A6C573888 + 24012
Synchronous URL loading of https://cr.dcloud.net.cn/collect/crash should not occur on this application's main thread as it may lead to UI unresponsiveness. Please switch to an asynchronous networking API such as URLSession.
Post crash result--[成功]--data--[]
libc++abi: terminating due to uncaught exception of type NSException
objc[89754]: Class _TtGC9Alamofire9ProtectedGSaFyT_T___ is implemented in both ?? (0x115b62330) and ?? (0x11709b7f8). One of the two will be used. Which one is undefined.
objc[89754]: Class _TtGC9Alamofire9ProtectedVCS*7Request12MutableState* is implemented in both ?? (0x115b62178) and ?? (0x11709b5b0). One of the two will be used. Which one is undefined.
objc[89754]: Class _TtGC9Alamofire9ProtectedGSaPS*12EventMonitor*__ is implemented in both ?? (0x1170a6e78) and ?? (0x11709aee0). One of the two will be used. Which one is undefined.
objc[89754]: Class _TtGCs18*DictionaryStorageCSo16NSURLSessionTaskC9Alamofire7Request* is implemented in both ?? (0x115b63d00) and ?? (0x1170a4e90). One of the two will be used. Which one is undefined.
objc[89754]: Class _TtGCs18*DictionaryStorageC9Alamofire7RequestCSo16NSURLSessionTask* is implemented in both ?? (0x115b638b8) and ?? (0x1170a4cb0). One of the two will be used. Which one is undefined.
objc[89754]: Class _TtGCs11*SetStorageC9Alamofire7Request* is implemented in both ?? (0x115b62c08) and ?? (0x1170a4018). One of the two will be used. Which one is undefined.
objc[89754]: Class _TtGCs23*ContiguousArrayStorageV9Alamofire10HTTPMethod* is implemented in both ?? (0x108499400) and ?? (0x11709bcf0). One of the two will be used. Which one is undefined.
objc[89754]: Class _TtGCs23*ContiguousArrayStorageP9Alamofire12EventMonitor*__ is implemented in both ?? (0x1170a67d8) and ?? (0x117099f28). One of the two will be used. Which one is undefined.
objc[89754]: Class _TtGCs23*ContiguousArrayStorageV9Alamofire10HTTPHeader* is implemented in both ?? (0x1170a5308) and ?? (0x1170998b8). One of the two will be used. Which one is undefined.
更多关于iOS项目中uni-app小程序sdk点击浏览大图崩溃的实战教程也可以访问 https://www.itying.com/category-93-b0.html
该bug反馈内容基本完整,标题、描述、复现步骤、预期/实际结果及分类信息齐全,但缺少关键代码示例,导致难以直接复现。崩溃日志显示为NSInvalidArgumentException(nil参数初始化字符串),发生在DCSliderImageImageItem组件中,表明图片浏览功能未正确处理空值参数。同时存在Alamofire库重复定义的警告,提示可能存在依赖冲突。
bug成立可能性高:首先,iOS 18是最新测试版系统,可能存在兼容性适配问题;其次,同步网络请求在主线程执行的警告符合崩溃特征;再者,uni-app SDK的图片浏览API若接收空数据源易触发此类异常。知识库未提供直接相关解决方案,但根据运行环境文档,需注意iOS平台特殊处理。
非基础概念问题,属于具体实现缺陷。建议用户:1) 检查调用uni.previewImage或image组件的代码,确保图片数组非空;2) 更新至最新版HBuilderX(当前反馈版本信息缺失,需确认是否低于4.87);3) 排查第三方库冲突,特别是Alamofire重复引入问题;4) 因iOS 18较新,可尝试在稳定版iOS系统验证。若问题持续,需提供完整代码片段以便进一步分析。 内容为 AI 生成,仅供参考
更多关于iOS项目中uni-app小程序sdk点击浏览大图崩溃的实战教程也可以访问 https://www.itying.com/category-93-b0.html
根据崩溃信息分析,这是一个典型的空字符串参数导致的异常。
核心问题:
崩溃堆栈显示 -[NSPlaceholderString initWithString:]: nil argument,说明在 DCSliderImageImageItem 的 setContentImageStyle:index: 方法中,传入了一个 nil 值给 NSString 的初始化方法。
可能原因:
- 图片路径为空:小程序中调用预览图片时,传入的图片路径数组可能包含空值或无效路径。
- 网络图片URL异常:如果预览的是网络图片,URL字符串可能为
null或格式不正确。 - SDK内部处理异常:uni-app SDK 在解析图片数据时,某个字符串参数意外为
nil。
解决方案:
-
检查小程序代码:
- 确认调用
uni.previewImage()时,urls参数数组中的每个元素都是有效的字符串 - 检查图片路径是否正确,特别是网络图片的URL是否完整
// 示例:确保urls数组中没有空值 uni.previewImage({ urls: this.imageList.filter(url => url && url.trim() !== ''), current: index }) - 确认调用

