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

Fix streamer activity in case of suspend #3488

Conversation

AKalinich-Luxoft
Copy link
Contributor

@AKalinich-Luxoft AKalinich-Luxoft commented Aug 31, 2020

Fixes #3160

This PR is ready for review.

Risk

This PR makes no API changes.

Testing Plan

[Describe how you plan to unit test the changes in this PR]

Summary

The problem of the current implementation is that SDL kills streaming thread responsible for sending a/v streaming data to HMI when streaming timeout expires. This issue is observed when mobile app dumps 10-seconds audio file to SDL during 2 seconds and after that app does not send any data. In that case HMI will play audio file during 2 seconds + timeout = 5 seconds. At the 5th second SDL just kills streaming thread with all pending messages, however audio service is still open. As a result not a whole audio file is played.

The correct behavior from SDL side in that case is not kill streaming thread when streaming timeout was expired. SDL should kill streaming thread only when service is actually stopped.

Current SDL behavior was updated to align with a correct behavior described above.

Tasks Remaining:

  • Test this fix

CLA

@AKalinich-Luxoft AKalinich-Luxoft force-pushed the fix/fix_streamer_activity_in_case_of_suspend branch 2 times, most recently from d3982a3 to 0c95e8a Compare September 1, 2020 19:09
@AKalinich-Luxoft AKalinich-Luxoft force-pushed the fix/fix_streamer_activity_in_case_of_suspend branch from 0c95e8a to ce5bce1 Compare September 3, 2020 23:36
The problem of the current implementation is that SDL
kills streaming thread responsible for sending a/v
streaming data to HMI when streaming timeout expires.
This issue is observed when mobile app dumps 10-seconds
audio file to SDL during 2 seconds and after that app
does not send any data. In that case HMI will play
audio file during 2 seconds + timeout = 5 seconds. At
the 5th second SDL just kills streaming thread with all
pending messages, however audio service is still open.
As a result not a whole audio file is played.

The correct behavior from SDL side in that case is not
kill streaming thread when streaming timeout was expired.
SDL should kill streaming thread only when service is
actually stopped.

Current SDL behavior was updated to align with a correct
behavior described above.
@AKalinich-Luxoft AKalinich-Luxoft force-pushed the fix/fix_streamer_activity_in_case_of_suspend branch from ce5bce1 to dcd7ce2 Compare September 5, 2020 16:24
Copy link
Collaborator

@iCollin iCollin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code changes only seem to affect the stream time of a stream that was suspended at some point. Am I correct that stream timeouts are not changed by this proposal unless a stream was suspended? I am confused because the issue and PR description seem to suggest otherwise, the examples and reproduction steps do not have any suspend in them, but the titles of both sound to match the code.

src/components/media_manager/src/media_manager_impl.cc Outdated Show resolved Hide resolved
@AKalinich-Luxoft
Copy link
Contributor Author

AKalinich-Luxoft commented Oct 1, 2020

The code changes only seem to affect the stream time of a stream that was suspended at some point. Am I correct that stream timeouts are not changed by this proposal unless a stream was suspended? I am confused because the issue and PR description seem to suggest otherwise, the examples and reproduction steps do not have any suspend in them, but the titles of both sound to match the code.

@iCollin you are right, the code changes does not change any streaming timeouts, but just updates SDL behavior little bit. This PR provides a new state for a streaming - kStopped, kStarted, kSuspended (was only stopped and started). This new state allows us to keep messages_ and streaming thread alive when streaming timeout has occurred (it was force stopped before these changes). That's why this new streaming state allows us to fix the issue described in PR.
Please let me know if you need some additional clarifications

@AKalinich-Luxoft
Copy link
Contributor Author

@iCollin I did a few things here:

  1. develop branch has been merged into this PR (f29a3e7)
  2. Changes from [WIP] initial fix of socket streaming by guessing playback time #3057 has been reverted in 3fd087e
  3. Unused code after revert has been removed in e6abe62

Please double check this PR one more time

case Application::StreamingState::kSuspended: {
// Don't stop activity in media_manager_ in that case
// Just cancel the temporary streaming state
state_ctrl_.OnVideoStreamingStopped(app);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this change the video state? Video could still be playing on the HMI if the app sent over a long video quickly.

Copy link
Contributor Author

@AKalinich-Luxoft AKalinich-Luxoft Oct 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@iCollin it just updates video streaming state via OnHMIStatus notification. This is an opposite action to what is done for kStarted case. Note that streaming may transit between suspended <-> started several times while service is opened so SDL should notify application each time on each such transition.
This also allows mobile proxy lib to decide should it stop a/v service or keep it alive. I know that SPT tracks such transitions during streaming and performs some actions.

@iCollin iCollin changed the base branch from develop to release/7.0.0 October 5, 2020 17:24
@iCollin iCollin merged commit 42721d5 into smartdevicelink:release/7.0.0 Oct 5, 2020
AKalinich-Luxoft added a commit to LuxoftSDL/sdl_core that referenced this pull request Jan 26, 2021
AKalinich-Luxoft added a commit to LuxoftSDL/sdl_core that referenced this pull request Jan 28, 2021
ShobhitAd pushed a commit that referenced this pull request Feb 12, 2021
…ignition cycle (#3468)

* Temporary commit to change URL of rpc_spec repository

* Change rpc_spec reference according to the new changes in the rpc_spec repo

* Add the new OnAppCapabilityUpdated RPC with appropriate types to the HMI_API

* Add the smart objects keys for the new parameters

* Add OnAppCapabilityUpdatedNotification and BCOnAppCapabilityUpdatedNotification

* Add Unit tests for the OnAppCapabilityUpdated RPCs

* Fix code generation for recursive structures

Currently InterfaceGenerator is not able to generate recursive structures
i.e. one or several structure attributes have its own type e.g.:
struct VideoStreamingCapability {
  ...
    VideoStreamingCapability
    additionalVideoStreamingCapabilities;
}
because structure type
fully defined only when all of it attributes are defined.
Otherwise param with type of structure will have AlwaysFalseSchema for
validation so this param will never be validated successfully.

With this commit InterfaceGenerator is able to handle such
problem.

* Update OnBCSystemCapabilityUpdatedNotificationFromHMITest Unit tests

Add the checking of the SystemCapabilityType::VIDEO_STREAMING in the message
and setting it into the HMICapabilities.

* Add additionalVideoStreamingCapabilities to default hmi_capabilities

* Add Processing OnSystemCapabilityUpdated with videoStreamingCapabilities

* Update Unit tests for OnSystemCapabilityUpdated notifications

* Add app_id to OnAppCapabilityUpdated notification to HMI

* Updates during code review

* Update logger

* Update link to rpc_spec

* Return back the driverDistractionCapability that was missed during conflicts resolving

* Fix functionality that was broken during conflicts resolving

* Updates during code review

* Update link to rpc_spec

* Revert "Fix streamer activity in case of suspend (#3488)"

This reverts commit 42721d5.

* Adjust old fix for all streaming transports

* Change commit to rpc_spec

* Update rpc_spec

* Mark function as deprecated

* Updates during code review

* Remove trailing whitespaces

* Update link to rpc_spec

* Update rpc_spec

Co-authored-by: Igor Gapchuk <igapchuck@luxoft.com>
Co-authored-by: YarikMamykin <ymamykin@gmail.com>
Co-authored-by: Andrii Kalinich <AKalinich@luxoft.com>
Co-authored-by: Dmitriy Boltovskiy <dboltovskyi@luxoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants