Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[UIApplication applicationState] called not from main thread #852

Closed
pierzyns opened this issue Jan 26, 2018 · 0 comments
Closed

[UIApplication applicationState] called not from main thread #852

pierzyns opened this issue Jan 26, 2018 · 0 comments
Assignees
Labels
best practice Not a defect but something that should be improved anyway
Milestone

Comments

@pierzyns
Copy link

Bug Report

XCode MainThread checker found an issue during connection into HU. The Issue is in function - (void)sendMobileHMIState in SDLProxy.m file. In this function there is called [UIApplication sharedApplication].applicationState; on the _receiveQueue workingQueue instead of Main Thread.

Reproduction Steps
  1. Enable the MainThread checker in Xcode
  2. Run the Application in debug mode
  3. Connect the the HU and try to use the app
Expected Behavior

[UIApplication sharedApplication].applicationState; must be used from main thread only.

Observed Behavior

[UIApplication sharedApplication].applicationState; is used from other thread.

OS & Version Information
  • iOS Version: 11.1.1
  • SDL iOS Version: 5.1.0
  • Testing Against: [What you tested with to observe this behavior]
Test Case, Sample Code, and / or Example App
#pragma mark - Application Lifecycle

- (void)sendMobileHMIState {
    UIApplicationState appState = [UIApplication sharedApplication].applicationState;
    SDLOnHMIStatus *HMIStatusRPC = [[SDLOnHMIStatus alloc] init];

    HMIStatusRPC.audioStreamingState = SDLAudioStreamingStateNotAudible;
    HMIStatusRPC.systemContext = SDLSystemContextMain;

    switch (appState) {
        case UIApplicationStateActive: {
            HMIStatusRPC.hmiLevel = SDLHMILevelFull;
        } break;
        case UIApplicationStateBackground: // Fallthrough
        case UIApplicationStateInactive: {
            HMIStatusRPC.hmiLevel = SDLHMILevelBackground;
        } break;
        default:
            break;
    }

    SDLLogD(@"Mobile UIApplication state changed, sending to remote system: %@", HMIStatusRPC.hmiLevel);
    [self sendRPC:HMIStatusRPC];
}
@joeljfischer joeljfischer self-assigned this Jan 29, 2018
@joeljfischer joeljfischer added this to the 5.2.0 milestone Jan 29, 2018
@joeljfischer joeljfischer added the best practice Not a defect but something that should be improved anyway label Jan 29, 2018
joeljfischer added a commit that referenced this issue Jan 29, 2018
* Fix application state should not be called off of main thread
@joeljfischer joeljfischer mentioned this issue Mar 16, 2018
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
best practice Not a defect but something that should be improved anyway
Projects
None yet
Development

No branches or pull requests

2 participants