JohanDegraeve / xdripswift

xdrip for iOS, written in Swift
GNU General Public License v3.0
339 stars 337 forks source link

App crashes on reconnecting #375

Open LiroyvH opened 2 years ago

LiroyvH commented 2 years ago

Go to Dexcom CGM, hit "stop scanning" and confirm you wish to disconnect. Go back to bluetooth. Tap your Dexcom. Now tap "scan". App will crash immediately. Upon re-opening the app, it does indeed resume scanning.

Full disclosure: only tested on iOS 16.

paulplant commented 2 years ago

Not reproducible on iOS 15.6.1 😅

nils-evert commented 2 years ago

Not reproducible on iOS 15.6.1 😅

Actually I can reproduce on 15.6.1

paulplant commented 2 years ago

Not reproducible on iOS 15.6.1 😅

Actually I can reproduce on 15.6.1

So... you can reproduce it every single time? Just by following the steps written by @LiroyvH ?

Are you using xDrip4iOS as the stand-alone master, or as a master using "Follow Dexcom-app" mode?

nils-evert commented 2 years ago

Not reproducible on iOS 15.6.1 😅

Actually I can reproduce on 15.6.1

So... you can reproduce it every single time? Just by following the steps written by @LiroyvH ?

Are you using xDrip4iOS as the stand-alone master, or as a master using "Follow Dexcom-app" mode?

I am using it as a master using Follow Dexcom-app Mode

https://user-images.githubusercontent.com/39710190/187091239-88a0ef6a-cf12-4f2a-b9d4-2e7db89972cf.MOV

LiroyvH commented 2 years ago

I'm in master mode, don't use the Dexcom app at all. Note that when trying to reproduce you must first go back to the Bluetooth screen or it won't crash. So disconnect, go back one step to bluetooth, tap your Dexcom again, now hit connect. Kaboom.

paulplant commented 2 years ago

I'm in master mode, don't use the Dexcom app at all. Note that when trying to reproduce you must first go back to the Bluetooth screen or it won't crash. So disconnect, go back one step to bluetooth, tap your Dexcom again, now hit connect. Kaboom.

Reproduced! I missed the step where I had to go back to the bluetooth peripherals screen and select again the Dexcom. It crashed straight away. Also in "Follow Dexcom-app" mode.

I'll check it out properly in the next days and discuss with Johan.

JohanDegraeve commented 2 years ago

It's probably because the number of rows in the table changes dynamically, bad programming from me actually. I know the issue occurs also in other cases.

Actually the app should automatically restart as soon as the Dexcom is ready to connect. Try this :

nils-evert commented 2 years ago

Within 5 minutes the value in the dexcom app was updated but after 10 minutes the value didn't change in xdrip4io5 (badge on app icon) and loop-dev (which takes the value from xdrip4io5) - I think it's not that urgent because as soon as you see the app crashing you usually would start it again manually. The crash doesn't happen without user interaction.

When I manually restarted the app after 10 minutes the values in xdrip4io5 and loop were only updated after the next cycle and xdrip4io5 showed "13 minutes ago" until then. So I think it wasn't relaunched by iOS automatically.

paulplant commented 2 years ago

It's probably because the number of rows in the table changes dynamically, bad programming from me actually. I know the issue occurs also in other cases.

Yes, that's what it is:

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of sections. The number of sections contained in the table view after the update (3) must be equal to the number of sections contained in the table view before the update (4), plus or minus the number of sections inserted or deleted (1 inserted, 1 deleted). Table view: <UITableView: 0x10892e680; frame = (0 129; 390 632); clipsToBounds = YES; autoresize = RM+BM; gestureRecognizers = <NSArray: 0x1079be950>; layer = <CALayer: 0x107773030>; contentOffset: {0, 0}; contentSize: {390, 1033.3333333333335}; adjustedContentInset: {0, 0, 0, 0}; dataSource: <xdrip.BluetoothPeripheralViewController: 0x107bc3a80>>'

Specifically it is the "Use Transmitter Algorithm" section that isn't shown when the app is not trying to connect to the transmitter (i.e. after we have clicked Disconnect). Instead of the 5 sections from before the update, this section is now not shown which leaves 4.

Tomorrow I'll look into it and try and fix it. The cool part is that this section is not defined in the G5/G6 view model so I need to find out where.