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

Default stack size change and Rolling buffer config rework #2011

Open
wants to merge 30 commits into
base: develop-pre-1.11.0
Choose a base branch
from

Conversation

disa6302
Copy link
Contributor

Issue #, if available:

What was changed?

  • Setting default stack size parameter to 0 (this means threads created with THREAD_CREATE will use platform specific thread stack size)
  • Reworked the rolling buffer config setting to move from setting fields in the RtcRtpTransceiverInit struct (which causes garbage values for config if the application does not memset the struct, leading to a crash) to surfacing an API to set up the values. The parameters are now internal to the SDK and can only be set up via this API call.
  • Cleaned up readme to have memory optimization related section

Why was it changed?

  • To ensure that devices do not run into stack overflow issues due to default 64KB constraint
  • To ensure the SDK is protected from garbage values

How was it changed?

  • Set KVS_STACK_SIZE to 0 in cmake if no value is provided explicitly.
  • createRollingBufferConfig API

What testing was done for the changes?

  • Added unit tests to test the new code
  • Added logging of the parameters to confirm the values are what they are supposed to be
  • Unit test run.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@codecov-commenter
Copy link

codecov-commenter commented Jun 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.66%. Comparing base (3824226) to head (2440dc0).

Current head 2440dc0 differs from pull request most recent head bd1420c

Please upload reports for the commit bd1420c to get more accurate results.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #2011      +/-   ##
===========================================
- Coverage    88.68%   88.66%   -0.02%     
===========================================
  Files           48       48              
  Lines        12726    12741      +15     
===========================================
+ Hits         11286    11297      +11     
- Misses        1440     1444       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@disa6302 disa6302 changed the title Default stack size change and Rollin gbuffer config rework Default stack size change and Rolling buffer config rework Jun 13, 2024
@disa6302 disa6302 marked this pull request as ready for review June 13, 2024 13:12
samples/Common.c Outdated Show resolved Hide resolved
niyatim23
niyatim23 previously approved these changes Jun 17, 2024
Copy link
Contributor

@niyatim23 niyatim23 left a comment

Choose a reason for hiding this comment

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

Nice!

CMakeLists.txt Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
samples/Common.c Outdated Show resolved Hide resolved
samples/Common.c Outdated Show resolved Hide resolved
samples/kvsWebRTCClientViewer.c Outdated Show resolved Hide resolved
tst/RtpRollingBufferFunctionalityTest.cpp Show resolved Hide resolved
stefankiesz
stefankiesz previously approved these changes Jun 18, 2024
Copy link
Contributor

@stefankiesz stefankiesz left a comment

Choose a reason for hiding this comment

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

LGTM!

stefankiesz
stefankiesz previously approved these changes Jun 18, 2024
pKvsRtpTransceiver->pRollingBufferConfig->rollingBufferDurationSec = rollingBufferDurationSec;
} else {
DLOGW("Rolling buffer duration does not fit range (%lf sec - %lf sec). Setting to default %lf sec", MIN_ROLLING_BUFFER_DURATION_IN_SECONDS,
MAX_ROLLING_BUFFER_DURATION_IN_SECONDS, DEFAULT_ROLLING_BUFFER_DURATION_IN_SECONDS);
Copy link
Contributor

Choose a reason for hiding this comment

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

You should add what the current value is set to. Also, should add "audio" and "video" for the duration lines.

The below logs are missing that info..

2024-06-28 23:40:41.721 WARN    setUpRollingBufferConfigInternal(): Rolling buffer duration does not fit range (0.100000 sec - 10.000000 sec). Setting to default 3.000000 sec
2024-06-28 23:40:41.721 WARN    setUpRollingBufferConfigInternal(): Rolling buffer bitrate does not fit range (104857.600000 bps - 251658240.000000 bps) for audio. Setting to default 1024000.000000 bps
2024-06-28 23:40:41.722 WARN    setUpRollingBufferConfigInternal(): Rolling buffer duration does not fit range (0.100000 sec - 10.000000 sec). Setting to default 3.000000 sec
2024-06-28 23:40:41.722 WARN    setUpRollingBufferConfigInternal(): Rolling buffer bitrate does not fit range (104857.600000 bps - 251658240.000000 bps) for video. Setting to default 5242880.000000 bps

if (pKvsRtpTransceiver != NULL) {
if (pKvsRtpTransceiver->pRollingBufferConfig == NULL) {
// Passing in 0,0. The default values will be set up since application has not set up rolling buffer config with the
// createRollingBufferConfig() call
Copy link
Contributor

Choose a reason for hiding this comment

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

It will also print out a bunch of extra logs (WARN)?

Copy link
Contributor

Choose a reason for hiding this comment

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

(making it look like an error of some kind)

@@ -1633,6 +1630,19 @@ typedef struct {
* @{
*/

/**
* @brief Set up rolling buffer configuration - max duration of media to store (sec) and expected max bitrate (bips) of the encoded media
Copy link
Contributor

Choose a reason for hiding this comment

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

In some areas, bips is used. Others, bps is used. Please adjust for consistency

remote timerQueueKick as it is causing TURN failures due to lock contention
remove timerQueueKick as it is causing TURN failures due to lock contention

For more information on these stats, refer to [AWS Docs](https://docs.aws.amazon.com/kinesisvideostreams-webrtc-dg/latest/devguide/kvswebrtc-reference.html)

The SDK **disables** generating these stats by default. In order to be enable the SDK to calculate these stats, the application needs to set the following field:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
The SDK **disables** generating these stats by default. In order to be enable the SDK to calculate these stats, the application needs to set the following field:
The SDK **disables** generating these stats by default. In order to enable the SDK to calculate these stats, the application needs to set the following field:

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.

6 participants