Skip to content
This repository has been archived by the owner on Feb 27, 2019. It is now read-only.

_BSMachError: (os/kern) when going to Settings #160

Closed
trozware opened this issue Mar 30, 2016 · 9 comments
Closed

_BSMachError: (os/kern) when going to Settings #160

trozware opened this issue Mar 30, 2016 · 9 comments
Labels

Comments

@trozware
Copy link

If permission is denied and the "Show Me" dialog button is tapped to go to Settings, the console shows 2 errors:

_BSMachError: (os/kern) invalid capability (20)
_BSMachError: (os/kern) invalid name (15)

This can be solved by using dispatch_after or dispatch_async on the main queue to open the Settings URL.

@nickoneill
Copy link
Owner

Ah, thanks for the tip @trozware! I'll work this into an upcoming release.

@winkelsdorf
Copy link

Maybe related to the project's "Localization native development region" in info.plist: http://stackoverflow.com/a/33465083/844907.

Anyhow, I cannot comment on the above ("en" is the default and should work).

For me it looks like an iOS bug, it is trigger by UIApplication.sharedApplication().openURL(settingsUrl!) when invoked by a handler.

Now the fun part, "fixing" it:

Current Call:

    let settingsUrl = NSURL(string: UIApplicationOpenSettingsURLString)
    UIApplication.sharedApplication().openURL(settingsUrl!) // error raised with this call

Solution: Explicitly invoke openURL on the main queue.

    dispatch_async(dispatch_get_main_queue()) {
        UIApplication.sharedApplication().openURL(settingsUrl!)
    }

Not what I want to see when invoking openURL, but this actually fixes the warning "for us". It's likely still logged in the iOS Console Logs, but Apple's fault, Apple's log.

Edit: Simplified fix.

@bre7 bre7 added the bug label Apr 20, 2016
@yichengsun
Copy link

yichengsun commented Aug 5, 2016

@nickoneill I'm having the same issue where app crashes after any of the app permissions changes (have tried camera, microphone, and location) while the app is in the background e.g. after pressing "Show Me" on the showDeniedAlert. Same error message as @trozware.

I've tried @winkelsdorf 's fix of invoking openURL on the main queue, but that only removed the console error. App still crashed. This is what my "Show Me" code looks like w/ the fix:

        alert.addAction(UIAlertAction(title: "Show me".localized,
            style: .Default,
            handler: { action in
                NSNotificationCenter.defaultCenter().addObserver(self, selector: Selector("appForegroundedAfterSettings"), name: UIApplicationDidBecomeActiveNotification, object: nil)

                let settingsUrl = NSURL(string: UIApplicationOpenSettingsURLString)
                dispatch_async(dispatch_get_main_queue()) {
                    UIApplication.sharedApplication().openURL(settingsUrl!)
                }
        }))

I've also tried the localization "en" to "United States" fix in info.plist with no effect.

Anything I am doing wrong?

Update: App crash seems to be only with the debugger on. Running the app w/out debugger and switching permissions while it is in background will cause the app to not crash but restart.

@nickoneill
Copy link
Owner

@yichengsun Yes - the crash isn't an issue with PermissionScope but as-designed for iOS. Changing certain permissions in the settings screen will terminate apps that have requested those permissions. This particular issue is related to fixing the warning only.

@yichengsun
Copy link

gotcha

@otymartin
Copy link

otymartin commented Aug 22, 2016

@nickoneill is there a solution at this point or will it just always crash?

@nickoneill
Copy link
Owner

There is no solution @otymartin, this is expected behavior from the OS. The situation is unchanged from 12 days ago.

@otymartin
Copy link

@nickoneill Yea it crashes while app is connected via USB but works fine on its own.

@bre7
Copy link
Collaborator

bre7 commented Oct 11, 2016

Closing as PS isn't to blame for this issue

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

6 participants