Githawk: 反应上下文菜单打开时间

创建于 2018-08-15  ·  14评论  ·  资料来源: GitHawkApp/GitHawk

对我来说,我个人希望它打开得更快一点。 只是太慢了,我不确定每次点击笑脸时我都按下了按钮 😃

使用GitHawk发送

🐛 bug 🎨 design

最有用的评论

@BrianLitwin子类UIApplication并覆盖sendEvent() 。 每次调用时设置一个全局Date 。 然后在按钮操作中我打印timeIntervalSinceNow

使用GitHawk发送

所有14条评论

如果它与经理按钮的速度相同就好了

使用GitHawk发送

哼,你说得对,确实感觉很笨重。 这是相同的代码! 有些东西肯定是关闭的。

在我发表声明之前,我要检查代码,但后来我没有。 😊。 概率应该有。

使用GitHawk发送

这必须与滚动视图延迟内容触摸有关。

使用GitHawk发送

经典滚动视图再次导致问题。

我不应该读这个:(

使用GitHawk发送

@BasThomas我知道,不能不看

使用GitHawk发送

哎哟😬哈哈

使用GitHawk发送

进行了一些调试以跟踪发送UIEvent和实际执行.touchUpInside操作之间的时间。 发现了一些有趣的堆栈跟踪。 开头的数字是UIApplication.sendEvent()和单元格中按钮操作处理之间的时间(以负秒为单位)的打印。

响应时间慢

-0.351912021636963
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 3.1
  * frame #0: 0x0000000100663448 Freetime`IssueCommentReactionCell.onAddButton(sender=0x000000014fc56f30, self=0x000000014fc55630) at IssueCommentReactionCell.swift:116
    frame #1: 0x00000001006635b0 Freetime`<strong i="11">@objc</strong> IssueCommentReactionCell.onAddButton(sender:) at IssueCommentReactionCell.swift:0
    frame #2: 0x000000018c6d164c UIKit`-[UIApplication sendAction:to:from:forEvent:] + 96
    frame #3: 0x00000001007310ec Freetime`Application.sendAction(action="onAddButtonWithSender:", target=some, sender=some, event=0x00000001cc11b090, self=0x0000000147f017c0) at Application.swift:21
    frame #4: 0x0000000100731334 Freetime`<strong i="12">@objc</strong> Application.sendAction(_:to:from:for:) at Application.swift:0
    frame #5: 0x000000018c7f2870 UIKit`-[UIControl sendAction:to:forEvent:] + 80
    frame #6: 0x000000018c6d7700 UIKit`-[UIControl _sendActionsForEvents:withEvent:] + 440
    frame #7: 0x000000018c80d1a8 UIKit`-[UIControl touchesEnded:withEvent:] + 572
    frame #8: 0x000000018ccb2ee8 UIKit`_UIGestureEnvironmentSortAndSendDelayedTouches + 4340
    frame #9: 0x000000018ccafc60 UIKit`_UIGestureEnvironmentUpdate + 1236
    frame #10: 0x000000018290a910 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 32
    frame #11: 0x0000000182908238 CoreFoundation`__CFRunLoopDoObservers + 412
    frame #12: 0x0000000182908884 CoreFoundation`__CFRunLoopRun + 1436
    frame #13: 0x0000000182828da8 CoreFoundation`CFRunLoopRunSpecific + 552
    frame #14: 0x000000018480e020 GraphicsServices`GSEventRunModal + 100
    frame #15: 0x000000018c848758 UIKit`UIApplicationMain + 236
    frame #16: 0x00000001003153f0 Freetime`main at main.swift:11
    frame #17: 0x00000001822b9fc0 libdyld.dylib`start + 4
(lldb) 

快速响应时间

-0.0017249584197998
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 3.1
  * frame #0: 0x0000000100663448 Freetime`IssueCommentReactionCell.onAddButton(sender=0x0000000147f62e90, self=0x0000000147f637a0) at IssueCommentReactionCell.swift:116
    frame #1: 0x00000001006635b0 Freetime`<strong i="7">@objc</strong> IssueCommentReactionCell.onAddButton(sender:) at IssueCommentReactionCell.swift:0
    frame #2: 0x000000018c6d164c UIKit`-[UIApplication sendAction:to:from:forEvent:] + 96
    frame #3: 0x00000001007310ec Freetime`Application.sendAction(action="onAddButtonWithSender:", target=some, sender=some, event=0x00000001c011be10, self=0x0000000147f017c0) at Application.swift:21
    frame #4: 0x0000000100731334 Freetime`<strong i="8">@objc</strong> Application.sendAction(_:to:from:for:) at Application.swift:0
    frame #5: 0x000000018c7f2870 UIKit`-[UIControl sendAction:to:forEvent:] + 80
    frame #6: 0x000000018c6d7700 UIKit`-[UIControl _sendActionsForEvents:withEvent:] + 440
    frame #7: 0x000000018c80d1a8 UIKit`-[UIControl touchesEnded:withEvent:] + 572
    frame #8: 0x000000018ccb2ee8 UIKit`_UIGestureEnvironmentSortAndSendDelayedTouches + 4340
    frame #9: 0x000000018ccafc60 UIKit`_UIGestureEnvironmentUpdate + 1236
    frame #10: 0x000000018c74a4d8 UIKit`-[UIGestureEnvironment _deliverEvent:toGestureRecognizers:usingBlock:] + 404
    frame #11: 0x000000018c74a010 UIKit`-[UIGestureEnvironment _updateGesturesForEvent:window:] + 276
    frame #12: 0x000000018c749874 UIKit`-[UIWindow sendEvent:] + 3132
    frame #13: 0x000000018c7481d0 UIKit`-[UIApplication sendEvent:] + 340
    frame #14: 0x0000000100730d54 Freetime`Application.sendEvent(event=0x00000001d011aa60, self=0x0000000147f017c0) at Application.swift:17
    frame #15: 0x0000000100730e18 Freetime`<strong i="9">@objc</strong> Application.sendEvent(_:) at Application.swift:0
    frame #16: 0x000000018cf29d1c UIKit`__dispatchPreprocessedEventFromEventQueue + 2340
    frame #17: 0x000000018cf2c2c8 UIKit`__handleEventQueueInternal + 4744
    frame #18: 0x000000018cf25368 UIKit`__handleHIDEventFetcherDrain + 152
    frame #19: 0x000000018290b404 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24
    frame #20: 0x000000018290ac2c CoreFoundation`__CFRunLoopDoSources0 + 276
    frame #21: 0x000000018290879c CoreFoundation`__CFRunLoopRun + 1204
    frame #22: 0x0000000182828da8 CoreFoundation`CFRunLoopRunSpecific + 552
    frame #23: 0x000000018480e020 GraphicsServices`GSEventRunModal + 100
    frame #24: 0x000000018c848758 UIKit`UIApplicationMain + 236
    frame #25: 0x00000001003153f0 Freetime`main at main.swift:11
    frame #26: 0x00000001822b9fc0 libdyld.dylib`start + 4
(lldb) 

每当触摸缓慢时,它_总是_大约有 0.35 秒的延迟。

快速响应跟踪中有趣的一点是:

frame #10: 0x000000018c74a4d8 UIKit`-[UIGestureEnvironment _deliverEvent:toGestureRecognizers:usingBlock:] + 404
    frame #11: 0x000000018c74a010 UIKit`-[UIGestureEnvironment _updateGesturesForEvent:window:] + 276
    frame #12: 0x000000018c749874 UIKit`-[UIWindow sendEvent:] + 3132
    frame #13: 0x000000018c7481d0 UIKit`-[UIApplication sendEvent:] + 340
    frame #14: 0x0000000100730d54 Freetime`Application.sendEvent(event=0x00000001d011aa60, self=0x0000000147f017c0) at Application.swift:17
    frame #15: 0x0000000100730e18 Freetime`<strong i="7">@objc</strong> Application.sendEvent(_:) at Application.swift:0
    frame #16: 0x000000018cf29d1c UIKit`__dispatchPreprocessedEventFromEventQueue + 2340
    frame #17: 0x000000018cf2c2c8 UIKit`__handleEventQueueInternal + 4744
    frame #18: 0x000000018cf25368 UIKit`__handleHIDEventFetcherDrain + 152
    frame #19: 0x000000018290b404 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24

__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__

这里有一些关于不同 runloop 方法的阅读

CFRunLoopSources “Version 0” 和 “Version 1” 实际上是非常不同的野兽,即使它们有一个共同的 API。 版本 0 源只是一种应用程序内消息传递机制,必须由应用程序代码手动处理。 在向版本 0 源发出信号(使用 CFRunLoopSourceSignal())后,必须唤醒 CFRunLoop(使用 CFRunLoopWakeUp())才能处理源。

__CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__

观察者有点特殊。 CFRunLoopObserver API 可让您观察 CFRunLoop 的行为并获知其活动:何时处理事件、何时​​进入睡眠状态等。它主要用于调试,您可能不需要在您的应用程序中使用它,但它是如果您想尝试 CFRunLoop 的功能,请在那里进行尝试。 [2014 年 10 月 2 日更新:事实上,它在某些用途上很有用:例如,CoreAnimation 从观察者标注运行。 这是有道理的:通过确保所有 UI 代码都已运行,它会立即执行所有动画。]

啊,找到了。 它是 b/c 在IssueCommentBaseCell上已经有一个UITapGestureRecognizer IssueCommentBaseCell供双击喜欢。 禁用该手势可以解决所有问题。

感谢您分享您的调查:)

使用GitHawk发送

@rnystrom你如何测量调用 UIEvent 和执行 .touchUpInside 之间的时间? 堆栈跟踪是否与您的最终解决方案有关?

@BrianLitwin子类UIApplication并覆盖sendEvent() 。 每次调用时设置一个全局Date 。 然后在按钮操作中我打印timeIntervalSinceNow

使用GitHawk发送

凉爽的。 这很聪明

使用GitHawk发送

此页面是否有帮助?
0 / 5 - 0 等级

相关问题

rnystrom picture rnystrom  ·  3评论

rnystrom picture rnystrom  ·  3评论

BasThomas picture BasThomas  ·  3评论

weyert picture weyert  ·  3评论

BasThomas picture BasThomas  ·  3评论