morizotter/SwiftyDrop

Crash at Drop.updateHeight()

t-yoshii opened this issue · 2 comments

Hi,

I am facing a crash at SwiftyDrop/SwiftyDrop/Drop.swift:130 with following stack trace.
SwittyDrop version is 3.0.3.

The direct cause is accessing nil Drop#statusLabel at SwiftyDrop/SwiftyDrop/Drop.swift:130.
I think the cause is receiving UIDeviceOrientationDidChange notification before Drop.setup is executed, therefore, accessing statusLabel inside updateHeight() fails.

Should the subscription of UIDeviceOrientationDidChange notification be started after setup?

Thread 1Queue : com.apple.main-thread (serial)
#0 0x00000001019311fc in specialized _fatalErrorMessage(StaticString, StaticString, StaticString, UInt, flags : UInt32) -> Never ()
#1 0x00000001017b5f14 in Drop.updateHeight() -> () at /snip/Pods/SwiftyDrop/SwiftyDrop/Drop.swift:130
#2 0x00000001017b5d00 in Drop.deviceOrientationDidChange(Notification) -> () at /snip/Pods/SwiftyDrop/SwiftyDrop/Drop.swift:99
#3 0x00000001017b60e0 in @objc Drop.deviceOrientationDidChange(Notification) -> () ()
#4 0x00000001821c0dfc in CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER ()
#5 0x00000001821c061c in _CFXRegistrationPost ()
#6 0x00000001821c039c in ___CFXNotificationPost_block_invoke ()
#7 0x0000000182229414 in -[_CFXNotificationRegistrar find:object:observer:enumerator:] ()
#8 0x00000001820fe6c8 in _CFXNotificationPost ()
#9 0x0000000182b0680c in -[NSNotificationCenter postNotificationName:object:userInfo:] ()
#10 0x0000000187409f3c in -[UIApplication _stopDeactivatingForReason:] ()
#11 0x000000018762a93c in -[UIApplication _runWithMainScene:transitionContext:completion:] ()
#12 0x0000000187627764 in -[UIApplication workspaceDidEndTransaction:] ()
#13 0x0000000183bbf7ac in FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK ()
#14 0x0000000183bbf618 in -[FBSSerialQueue _performNext] ()
#15 0x0000000183bbf9c8 in -[FBSSerialQueue _performNextFromRunLoopSource] ()
#16 0x00000001821d509c in CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION ()
#17 0x00000001821d4b30 in __CFRunLoopDoSources0 ()
#18 0x00000001821d2830 in __CFRunLoopRun ()
#19 0x00000001820fcc50 in CFRunLoopRunSpecific ()
#20 0x00000001873ef94c in -[UIApplication _run] ()
#21 0x00000001873ea088 in UIApplicationMain ()
#22 0x00000001000abb5c in main at /snip/AppDelegate.swift:13
#23 0x0000000181c9a8b8 in start ()

When did you face crash?

Anyway, your pr is merged ;) If the crash reproduced please tell me again!

Thanks for merging PR!

In certain condition, my app could call 'Drop.down()' at the very early timing of app startup (applicationDidFinishLaunching(_:) phase. I know this is not good), this crash occurs in this call.
In normal use case, crash does not occur.