InfiniTimeOrg / InfiniLink

The official iOS companion app for InfiniTime
https://apps.apple.com/us/app/infinilink/id1582318814
GNU General Public License v3.0
202 stars 22 forks source link

Crash in converting time to send to music service #47

Closed xan-m closed 2 years ago

xan-m commented 2 years ago

A couple users have experienced crashes in the convertTime function of the MusicController class. I don't see anything outstandingly unsafe about this, but more than one crash has occurred here so something is wrong.\

The specific line that the crashlog flags is let val32 : UInt32 = UInt32(floor(value)), where value is a Double passed as an argument into the function, so it shouldn't be a nil value problem. Not sure if it's a conversion issue to UInt32 or a problem with the floor function.

@WowieMan any ideas here?

WowieMan commented 2 years ago

Not exactly sure what's causing the problem, but I'll look into it and see if I can fix it.

xan-m commented 2 years ago

Thank you! It's 2 verified crashes out of 500 sessions, so whatever is causing it might be a bit of a goose chase, and also is not a super urgent bug.

I didn't read too much into currentPlaybackTime, is there any way this or it's floored value could be enough to overflow a UInt32? That seems like the most likely cause of crash in this situation. A Double is 64 bits in Swift.

WowieMan commented 2 years ago

Well I did some testing and it's looks like the crash might've been caused by the value being above UInt32 max value. I've created a pull request that should fixes the issues.