iOS App Crash - Assertion Failed

When I try my app in background, after a few seconds, it crashes. I've already try to delete my app from the device. This is the log in console:

Unknown error calling sqlite3_step (10: disk I/O error) rs

Unknown error calling sqlite3_step (10: disk I/O error) rs

Unknown error calling sqlite3_step (10: disk I/O error) rs

Assertion failed: (success), function __26-[MBLMetaWear synchronize]_block_invoke, file /Users/sschiffli/Code/metawear-ios-api/MetaWear/MBLMetaWear.m, line 850.

(lldb)


Comments

  • I had the same issue - mine was a dispatch_async/ UI thread issue.
  • What did you do to resolve it?
  • We have successfully used backgrounding in apps before, and I don't ever remember seeing this issue.  Is there anyway you can share the project source or provide more details around what functions are being called in the background?
  • It comes up only when I lock the iPhone. I tried in background unlocked and it doesn't crash.

    I don't call any function in background (as the iOS sample app). Maybe is there a function for when iPhone is locked?
  • What version of iOS are you running on your device?
  • edited March 2016
    Adrenocortico

    I'd have to see your code, and my is in Swift, so not sure it would help. I had to use dispatch_async to update screen values, etc. Just guessing, but it seems like your app might be trying to force a UI update or something while running in the background.


        dispatch_async(dispatch_get_main_queue(), ^{
            // update some UI
        });

  • @stephen: I've got iOS 9.3, is this the problem?

    @stu68: I use both swift and obj-c and my app until last week worked fine.
  • edited March 2016
    If it could be useful, my code crash (when iPhone is locked) when "a" of the if cycle is true, so when the hapticBuzzer starts.

    [self.streamingEvents addObject:self.device.accelerometer.dataReadyEvent];

    [self.device.accelerometer.dataReadyEvent startNotificationsWithHandlerAsync:^(MBLAccelerometerData * _Nullable acceleration, NSError * _Nullable error) {

        if (acceleration) {

          [array addObject:acceleration];

          if (a == true) {

            [self.device.hapticBuzzer startHapticWithDutyCycleAsync:220 pulseWidth:350 completion:nil];

          };

        }










































      }];

  • I've been unable to reproduce here, but here is a random thought that could help:

    The frequency of accelerometer data is usually pretty fast (100Hz default), so based on the code linked it would be telling the haptic to buzz for 350ms ever 10ms.  Of course this all depends on where or how "a" is calculated, but double check you aren't trying to buzz the haptic at a high frequency.
  • I've tried to change the frequency of accelerometer but it doesn't work. Can I sent an email to hello@mbientlab.com with the code for a review?
  • hello at mbientlab is primarily for business inquiries.  Unless you are planning on paying for software services, technical questions, like the one you have, should be resolved in a public forum as it may help others who have similar problems.  Copy your code to pastebin, GitHub gist, or any website with syntax highlighting and put a link to it in this thread.
  • I've put my code in this gist. Someone could you try to help me? The problem still remain also with the 2.3.2 and it's always the bug: Assertion failed: (success), function __26-[MBLMetaWear synchronize]_block_invoke, file /Users/sschiffli/Code/metawear-ios-api-develop/MetaWear/MBLMetaWear.m, line 850.
    It comes out when I try to use the app when the iPhone is locked, it never came out during the background or active mode.
  • Looks like this has to do with Enabling Data Protection (iOS, WatchKit Extension, tvOS) on an App.  With that enabled, files are encrypted and not accessible when the device is locked by default.  Looking at the available File Protection Values I think NSFileProtectionCompleteUntilFirstUserAuthentication is the most appropriate value for the files accessed by the SDK.  I've made this change and it will be in the next SDK release.

    Thanks!
    -Stephen
  • Hi @stephen ! Thanks for the help! I tried to remove the Data Protection but the result has not changed: after a short time, with the iPhone locked, the app crashes.

    So I tried to create a new app from scratch (without touching the .plist file) using my code and the result is not changed.

    Finally I tried to put my code in your app Metawear-SampleiOSApp and the app does not crash.

    I do not understand why this happens: it's something in the .plist file or in your app settings? It may be the problem in the Custom iOS Target Properties or in the Build Settings?

    Thanks anyway, and again, for the help!
  • I tried to change ONLY the Bundle Identifier of my app in com.mbientlab.MetaWear test API and finally it works for me: the application doesn't crash anymore.

    Now I'd like to know why so happens. Has someone an idea?
  • Glad you got things working!

    I know the crash occurred because of file protection, i.e. framework trying to write to a file when it didn't have sufficient permission.  It's hard to say why exactly turning off Data Protection didn't fix it, but changing the bundle ID did.  Those attributes are probably cached in iOS somehow.
  • It makes me happy that you too @stephen do not know exactly why turning off Data Protection did not fix it ;).

    Now I have tried replacing the Bundle Identifier in com.adrenocortico.MetaWearAPITest and the app works perfectly.

    I still do not understand why, but I remain happy as long as it works ;)!
  • Xcode 7.3.1 may have fixed this:






    Fixed the issue that left associated entitlements in an app still enabled after disabling a capability in the Xcode UI. With this fix, Xcode copies entitlements for Wallet, GameCenter (for OS X), Data Protection, and Push Notifications when building an app. Other entitlements are not copied unless they are declared in the app entitlements plist. (24771364)

This discussion has been closed.