【问题标题】:HockeyApp crash, forked Queues, iOS, SwiftHockeyApp 崩溃、分叉队列、iOS、Swift
【发布时间】:2018-02-27 16:11:34
【问题描述】:

使用来自 GitHub 的其他人的框架来实现 UIButton Process 效果。 通过最新的 XCode 安装时工作正常,但如果通过 HockeyApp 安装,应用程序会在按钮开始动画时立即崩溃。 这是有问题的动画功能:

  private func startAnimating() {
    isAnimating = true
    views = []

    for i in 0..<colors.count {
        let view = UIView(frame: lineRect())
        view.backgroundColor = colors[i]
        views.append(view)
    }

         dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), { () -> Void in

        var count: Int = 0
        while self.isAnimating {
            if count == self.views.count {
                count = 0
            }

            var next = false
            dispatch_async(dispatch_get_main_queue(), {

                UIView.animateWithDuration(self.duration, delay: 0, options: [], animations: { () -> Void in
                    if self.isAnimating {

                        if !self.views.isEmpty {
                        self.addSubview(self.views[count])
                        self.views[count].frame.origin = CGPoint(x: self.bounds.origin.x, y: 0)
                        self.views[count].frame.size.width = self.frame.width
                        }
                    }
                    }, completion: { (Bool) -> Void in
                        if self.isAnimating {
                            var lastIndex = count - 1
                            if lastIndex < 0 {
                                lastIndex = self.colors.count - 1
                            }
                            self.views[lastIndex].frame = self.lineRect()
                            self.views[lastIndex].removeFromSuperview()
                        }
                        next = true
                })
            })

            // Let's wait until the current animation is done before moving forward
            while !next {
            }
            count++
        }
    })

}

HockeyApp 指向第二个队列中“views”的第一个引用,在本例中是空检查(我已添加,但如果不存在,它将指向下一个引用):

 UIView.animateWithDuration(self.duration, delay: 0, options: [], animations: { () -> Void in
                        if self.isAnimating {

                            if !self.views.isEmpty {
                            self.addSubview(self.views[count])
                            self.views[count].frame.origin = CGPoint(x: self.bounds.origin.x, y: 0)
                            self.views[count].frame.size.width = self.frame.width
                            }
                        }

这是 HockeyApp 崩溃报告的关键部分:

Date/Time:       2016-02-03T18:01:01Z
Launch Time:     2016-02-03T18:00:33Z
OS Version:      iPhone OS 9.2.1 (13D15)
Report Version:  104

Exception Type:  SIGTRAP
Exception Codes: #0 at 0x100099080
Crashed Thread:  0

Application Specific Information:
Selector name found in current argument registers: release

Thread 0 Crashed:
0   barscan1                             0x0000000100099080 barscan1.ProcessView.((startAnimating in _126B4789AED4AC2C363037724C3D4FEF) (barscan1.ProcessView) -> () -> ()).(closure #1).(closure #1).(closure #1) (ProcessView.swift:78)
1   UIKit                                0x0000000185eb8210 +[UIView(UIViewAnimationWithBlocks) _setupAnimationWithDuration:delay:view:options:factory:animations:start:animationStateGenerator:completion:] + 616
2   UIKit                                0x0000000185ecfc58 +[UIView(UIViewAnimationWithBlocks) animateWithDuration:delay:options:animations:completion:] + 104
3   barscan1                             0x0000000100098d90 barscan1.ProcessView.((startAnimating in _126B4789AED4AC2C363037724C3D4FEF) (barscan1.ProcessView) -> () -> ()).(closure #1).(closure #1) (ProcessView.swift:94)
4   libdispatch.dylib                    0x0000000180be1630 _dispatch_call_block_and_release + 20
5   libdispatch.dylib                    0x0000000180be15f0 _dispatch_client_callout + 12
6   libdispatch.dylib                    0x0000000180be6cf8 _dispatch_main_queue_callback_4CF + 1840
7   CoreFoundation                       0x0000000181144bb0 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 8
8   CoreFoundation                       0x0000000181142a18 __CFRunLoopRun + 1624
9   CoreFoundation                       0x0000000181071680 CFRunLoopRunSpecific + 380
10  GraphicsServices                     0x0000000182580088 GSEventRunModal + 176
11  UIKit                                0x0000000185ee8d90 UIApplicationMain + 200
12  barscan1                             0x00000001000aa32c main (AppDelegate.swift:15)
13  ???                                  0x0000000180c128b8 0x0 + 0

非常感谢任何帮助! 谢谢!

【问题讨论】:

    标签: ios xcode swift hockeyapp


    【解决方案1】:

    原来这是 Apple 的 Swift 优化的问题 - 将其设置为 NONE,现在问题就消失了。

    【讨论】:

    • 请注意,您不应永久禁用这些优化,因为它们可能会显着减慢您的代码速度。如果可以,也请向 Apple 提交错误,以便他们更好地进行修复。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多