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

Mark keySystemAccess as default to null and optional and robustness properties as no longer defaulting. #107

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

mounirlamouri
Copy link
Member

@mounirlamouri mounirlamouri commented Nov 23, 2018

This is solving two issues:

  • required for an object seems to not allow null, at least in Chrome bindings. It occurs to me that defaulting to null is doing what we were trying to achieve and works better with the bindings. I will assume that Chrome bindings are following the spec here. I did not double-check.
  • Setting a default value for robustness means that in the steps where we compare with video and audio being present, we actually are always doing the check because per WebIDL, a property with a default value is always present. I had to put in prose the default value.

Preview | Diff


Preview | Diff

@chcunningham
Copy link
Contributor

chcunningham commented Nov 30, 2018

For robustness, its a little weird to have some fields in the dictionary with defaults and others without due to this validity nuance. What if we patch the validity algo to say:

If keySystemConfiguration.audioRubstness is not the empty string (""), audio MUST also be present.

Also, I misspelled audioRubstness and videoRubstness in the spec.

@mounirlamouri
Copy link
Member Author

mounirlamouri commented Nov 30, 2018

I think the only edge case where your solution wouldn't catch an issue is if someone does set audioRobustness: '' but doesn't set an audio configuration. In my proposal, we would reject but with your solution we wouldn't. The difference is that in EME you set the contentType and the robustness in the same object for video and audio separately so there is no need to guarantee consistency.

Edit: we can also purposefully keep this edge case not covered but I'm not sure it's worth doing just for the sake of a cleaner IDL.

@chcunningham
Copy link
Contributor

I think the only edge case where your solution wouldn't catch an issue is if someone does set audioRobustness: '' but doesn't set an audio configuration.

Maybe thats a good thing? If empty is effectively the default (via algo), and if empty means "no robustness requirements", then having someone explicitly set this field to empty doesn't have to be an error if audio isn't present. Its a bit weird for a user to do this, but it doesn't break us or make the input ambiguous so I don't mind.

I think both IDL and algo are simpler this route.

@mounirlamouri
Copy link
Member Author

Just to clarify, the case I have in mind is:

{
  video: {
    contentType: 'video/webm;codecs=vp9',
  },
  keySystemConfiguration: {
    keySystem: 'org.w3.clearkey',
    audioRobustness: '',
  }
}

which would translate in EME to something like:

{
  audioCapabilities: [
    { robustness: '' },
  ],
  videoCapabilities: [
    { contentType: 'video/webm; codecs="vp9"' },
  ],
}

and would therefore not be valid.

We would need to at least add logic to handle this case.

index.bs Outdated
@@ -461,8 +461,8 @@ spec: workers; urlPrefix: https://www.w3.org/TR/workers/#
dictionary MediaCapabilitiesKeySystemConfiguration {
required DOMString keySystem;
DOMString initDataType = "";
Copy link
Contributor

Choose a reason for hiding this comment

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

What do you think of doing the same thing to initDataType. It suffers the same issue of always being present.

Copy link
Member Author

Choose a reason for hiding this comment

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

The problem is different: for audio and video robustness, we have logic that says that if you set one or the other, there must be a configuration. Issue is that if you create a MediaCapabilitiesKeySystemConfiguration, per spec, it will set these two properties and always fail the check in https://w3c.github.io/media-capabilities/#mediaconfiguration

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is resolved by #138 (the nested audio/video =dictionary is optional and non-defaulted)

index.bs Outdated Show resolved Hide resolved
index.bs Outdated
@@ -743,9 +742,18 @@ spec: workers; urlPrefix: https://www.w3.org/TR/workers/#
<code>config.audio.contentType</code>.
</li>
<li>
Set the {{EME/robustness}} attribute to
Let <var>robustness</var> be a string <code>DOMString</a>
initialized to the empty string (<code>""</code>).
Copy link
Contributor

Choose a reason for hiding this comment

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

After sitting on this a bit more I think the approach is fine.

We might simplify what you have here even further with something like:
"if audioRobustness is present, set EME robustness attribute to config.keySystemConfig.audioRobustness"

And simply do nothing if it audioRobustness is not present. The default value from the EME config is "", so doing nothing should cause that default to take hold.

Maybe thats too subtle? Open to either route.

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't have a strong opinion. In general, I find having clear defaults better than relying on side effects but if you feel strongly, I'm happy to update the PR.

Copy link
Contributor

@chcunningham chcunningham Aug 16, 2019

Choose a reason for hiding this comment

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

"be a string DOMString"

Do you mean to say 'string' twice - just DOMString?

Set the robustness attribute to robustness.

How about this change in wording/style?

If config.keySystemConfiguration.videoRobustness is present, set robustness to config.keySystemConfiguration.videoRobustness. Otherwise, set robustness to "".

Copy link
Member Author

Choose a reason for hiding this comment

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

I fixed "string DOMString".

For the wording, the way I see it is that I prefer:

let robustness = "";
if (config.keySystemConfiguration.videoRobustness)
  robustness = config.keySystemConfiguration.videoRobustness;

over:

let robustness = config.keySystemConfiguration.videoRobustness
                               ? config.keySystemConfiguration.videoRobustness
                               : "";

(reason is that I prefer to have the default clear if there is one)

It's pretty much the same at the end so if you think it's clearer, I'm happy to apply the change.

@chcunningham
Copy link
Contributor

I think with the recent change to nest robustness under a track config, the default of "" is no longer at odds with present (you check for the parent).

But the null key system access still makes sense.

@markafoltz
Copy link
Contributor

I rebased this PR, but it seems to have been based on an earlier version of the spec, so it will need more updates before it can land.

@markafoltz
Copy link
Contributor

The prose now should make sense with the current spec. I also incorporated the change from #223 since that was discussed as part of this PR.

I am not convinced that the spec steps need to be explicit about the default for robustness though. It is defined as a non-nullable DOMString in the IDL, it already has a default of "", and the corresponding EME attribute has a default of "".

Also note that the situation #107 (comment) (an audio robustness property without an audio KeySystemTrackConfiguration) is no longer possible.

It may be enough to check that it exists in the dictionary before copying the value over.

@markafoltz
Copy link
Contributor

@xhwang-chromium If you have time to take a look it would be appreciated, as this deals with the EME integration part of the spec.

@xhwang-chromium
Copy link
Contributor

In the IDL, robustness is already default to empty:

dictionary KeySystemTrackConfiguration {
  DOMString robustness = "";
  DOMString? encryptionScheme = null;
};

I it seems to me we don't need to have an explicit step to assign empty string to robustness if it's not specified. This is the same as how robustness in EME is handled.

@markafoltz
Copy link
Contributor

Updated per feedback from @xhwang-chromium to remove the robustness default.

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.

keySystemAccess in MediaCapabilitiesDecodingInfo should be nullable in the dictionary declaration
6 participants