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

Video stream is stopped and restarted immediately when app enters background #858

Closed
NicoleYarroch opened this issue Feb 1, 2018 · 6 comments
Assignees
Labels
bug A defect in the library
Milestone

Comments

@NicoleYarroch
Copy link
Contributor

NicoleYarroch commented Feb 1, 2018

Bug Report

When app enters the background, video streaming should pause until the app re-enters the foreground. Currently, video streaming stops and then restarts immediately. A SDLVideoStreamDidStart notification is sent even when the app is in the background.

Reproduction Steps
  1. Connect a video streaming app (appType = NAVIGATION) to Core.
  2. Once video streaming has started, put the app on the iPhone into the background.
Expected Behavior

The SDLVideoStreamDidStart notification is not sent until the app on the iPhone is brought to the foreground.

Observed Behavior

The SDLVideoStreamDidStart notification is sent while the app is still in the background.

OS & Version Information
  • iOS Version: 11.2
  • SDL iOS Version: 5.1
  • Testing Against: SDL Core 4.4
@NicoleYarroch NicoleYarroch added the bug A defect in the library label Feb 2, 2018
@SatbirTanda
Copy link
Contributor

SatbirTanda commented Feb 20, 2018

I can't reproduce this, I'm not seeing SDLVideoStreamDidStartNotification firing when the app goes to the background and I do not see the selector sdl_didReceiveVideoStreamStarted being called for the notification until the app comes back into the foreground.

@NicoleYarroch
Copy link
Contributor Author

@SatbirTanda This was an issue reported by @rafal on the Slack channel. Is your setup for video streaming different from the documentation? If so, can you post your setup here? If not, we will close this issue.

@pierzyns
Copy link

The setup is according to the documentation. I even can show you place in the code which causes the error.

- (void)didEnterStateAppInactive {
    SDLLogD(@"App became inactive");
    if (!self.protocol) { return; }

    [self sdl_sendBackgroundFrames];
    [self.touchManager cancelPendingTouches];
    self.restartVideoStream = YES;
}
- (void)didEnterStateVideoStreamStopped {
    SDLLogD(@"Video stream stopped");
    _videoEncrypted = NO;
    _videoFormat = nil;

    if (_videoEncoder != nil) {
        [_videoEncoder stop];
        _videoEncoder = nil;
    }

    self.displayLink.paused = YES;
    [self.displayLink invalidate];

    [[NSNotificationCenter defaultCenter] postNotificationName:SDLVideoStreamDidStopNotification object:nil];

    if (self.shouldRestartVideoStream) {
        self.restartVideoStream = NO;
        [self sdl_startVideoSession];
    }
}

Function didEnterStateAppInactive is called on notification UIApplicationWillResignActiveNotification and in this function property restartVideoStream is set to yes. Then, when the video streaming stops the function didEnterStateVideoStreamStopped is called and when property restartVideoStream is set to yes the video streaming starting again.

@joeljfischer joeljfischer added this to the 5.2.0 milestone Feb 21, 2018
@pierzyns
Copy link

logs.txt
Here are logs from iOS SDL SDK which shows the issue

@NicoleYarroch NicoleYarroch self-assigned this Feb 26, 2018
@NicoleYarroch
Copy link
Contributor Author

NicoleYarroch commented Feb 26, 2018

I have reproduced this bug with SDL_iOS v. 5.1.1. It appears that the video and audio streams are restarted when the app re-enters the foreground. I am working on a fix.

@NicoleYarroch
Copy link
Contributor Author

A pull request has been created to fix this bug.

@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
bug A defect in the library
Projects
None yet
Development

No branches or pull requests

4 participants