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: Do not report MANIFEST RESTRICTIONS_CANNOT_BE_MET error twice #4194

Conversation

albertdaurell
Copy link
Contributor

@albertdaurell albertdaurell commented May 4, 2022

Description

We want to avoid reporting MANIFEST RESTRICTIONS_CANNOT_BE_MET error twice.
This is because when error detected from onKeyStatus_ calls updateAbrManagerVariants_ which calls checkRestrictedVariants_ and error is catched and propagated from onError_ but source code execution continues
and chooseVariantAndSwitch_ triggers same error again:

onKeyStatus_() {
  ....
  if (tracksChanged) {
    this.updateAbrManagerVariants_(); 
    //   -> checkRestrictedVariants_ 
    //     -> RESTRICTIONS_CANNOT_BE_MET
  }
  ...
  if (currentVariant && !currentVariant.allowedByKeySystem) {
    ...
    this.chooseVariantAndSwitch_(); 
    //  -> chooseVariant_
    //    -> updateAbrManagerVariants_ 
    //      -> checkRestrictedVariants_ 
    //        -> RESTRICTIONS_CANNOT_BE_MET
  }

Resolves

#4190

@avelad avelad requested a review from theodab May 4, 2022 11:13
@avelad avelad added the type: bug Something isn't working correctly label May 4, 2022
@avelad avelad requested a review from joeyparrish May 5, 2022 16:05
Copy link
Member

@joeyparrish joeyparrish left a comment

Choose a reason for hiding this comment

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

It would be nice to have a regression test for this, so that a future refactor doesn't introduce the error again. @albertdaurell, please follow-up with a test that fails without the fix and passes with it.

@joeyparrish joeyparrish merged commit 08589e8 into shaka-project:main May 5, 2022
@avelad avelad added this to the v4.1 milestone May 5, 2022
@albertdaurell
Copy link
Contributor Author

It would be nice to have a regression test for this, so that a future refactor doesn't introduce the error again. @albertdaurell, please follow-up with a test that fails without the fix and passes with it.

Thx @joeyparrish. Here it is #4205

@albertdaurell albertdaurell deleted the feature/report-restrictions-cannot-be-met-once branch May 9, 2022 18:26
joeyparrish pushed a commit that referenced this pull request May 9, 2022
…4205)

Adding tests for #4194 in order to ensure that, when `onKeyStatus({ kid: 'output-restricted'})` error is thrown **ONLY** one `RESTRICTIONS_CANNOT_BE_MET` error is triggered/thrown.
joeyparrish pushed a commit that referenced this pull request May 17, 2022
…4194)

We want to avoid reporting MANIFEST RESTRICTIONS_CANNOT_BE_MET error twice.

This is because when error detected from `onKeyStatus_` calls `updateAbrManagerVariants_` which calls `checkRestrictedVariants_` and error is catched and propagated from `onError_` **but source code execution continues** 
and `chooseVariantAndSwitch_` triggers same error again:

```javascript
onKeyStatus_() {
  ....
  if (tracksChanged) {
    this.updateAbrManagerVariants_(); 
    //   -> checkRestrictedVariants_ 
    //     -> RESTRICTIONS_CANNOT_BE_MET
  }
  ...
  if (currentVariant && !currentVariant.allowedByKeySystem) {
    ...
    this.chooseVariantAndSwitch_(); 
    //  -> chooseVariant_
    //    -> updateAbrManagerVariants_ 
    //      -> checkRestrictedVariants_ 
    //        -> RESTRICTIONS_CANNOT_BE_MET
  }
```

Closes #4190
joeyparrish pushed a commit that referenced this pull request May 17, 2022
…4205)

Adding tests for #4194 in order to ensure that, when `onKeyStatus({ kid: 'output-restricted'})` error is thrown **ONLY** one `RESTRICTIONS_CANNOT_BE_MET` error is triggered/thrown.
joeyparrish pushed a commit that referenced this pull request May 17, 2022
…4194)

We want to avoid reporting MANIFEST RESTRICTIONS_CANNOT_BE_MET error twice.

This is because when error detected from `onKeyStatus_` calls `updateAbrManagerVariants_` which calls `checkRestrictedVariants_` and error is catched and propagated from `onError_` **but source code execution continues** 
and `chooseVariantAndSwitch_` triggers same error again:

```javascript
onKeyStatus_() {
  ....
  if (tracksChanged) {
    this.updateAbrManagerVariants_(); 
    //   -> checkRestrictedVariants_ 
    //     -> RESTRICTIONS_CANNOT_BE_MET
  }
  ...
  if (currentVariant && !currentVariant.allowedByKeySystem) {
    ...
    this.chooseVariantAndSwitch_(); 
    //  -> chooseVariant_
    //    -> updateAbrManagerVariants_ 
    //      -> checkRestrictedVariants_ 
    //        -> RESTRICTIONS_CANNOT_BE_MET
  }
```

Closes #4190
joeyparrish pushed a commit that referenced this pull request May 17, 2022
…4205)

Adding tests for #4194 in order to ensure that, when `onKeyStatus({ kid: 'output-restricted'})` error is thrown **ONLY** one `RESTRICTIONS_CANNOT_BE_MET` error is triggered/thrown.
joeyparrish pushed a commit that referenced this pull request May 17, 2022
…4194)

We want to avoid reporting MANIFEST RESTRICTIONS_CANNOT_BE_MET error twice.

This is because when error detected from `onKeyStatus_` calls `updateAbrManagerVariants_` which calls `checkRestrictedVariants_` and error is catched and propagated from `onError_` **but source code execution continues** 
and `chooseVariantAndSwitch_` triggers same error again:

```javascript
onKeyStatus_() {
  ....
  if (tracksChanged) {
    this.updateAbrManagerVariants_(); 
    //   -> checkRestrictedVariants_ 
    //     -> RESTRICTIONS_CANNOT_BE_MET
  }
  ...
  if (currentVariant && !currentVariant.allowedByKeySystem) {
    ...
    this.chooseVariantAndSwitch_(); 
    //  -> chooseVariant_
    //    -> updateAbrManagerVariants_ 
    //      -> checkRestrictedVariants_ 
    //        -> RESTRICTIONS_CANNOT_BE_MET
  }
```

Closes #4190
joeyparrish pushed a commit that referenced this pull request May 17, 2022
…4205)

Adding tests for #4194 in order to ensure that, when `onKeyStatus({ kid: 'output-restricted'})` error is thrown **ONLY** one `RESTRICTIONS_CANNOT_BE_MET` error is triggered/thrown.
nyanmisaka added a commit to nyanmisaka/shaka-player that referenced this pull request Oct 6, 2022
@github-actions github-actions bot added the status: archived Archived and locked; will not be updated label Jul 25, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: archived Archived and locked; will not be updated type: bug Something isn't working correctly
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants