Re: [mediacapture-main] Fitness distance steps 4 and 5 are inconsistent with the rest of the spec (#933)

> But the concept we are interested in is whether a dictionary setting satisfies a constraint or not, see [Step 2](https://w3c.github.io/mediacapture-main/#dfn-fitness-distance). Thus, having a numeric setting and a boolean value for the constraint doesn't mean that the setting cannot be checked to satisfy the constraint. IIUC, if the setting supports any numeric value it means it satisfies a true value for the constraint. I see no need to add additional language there other than specifying how to compute the numeric values for the fitness in a step specific to (boolean or ConstraintDouble).

Oh, I see now that the step 4 is worded so that it applies both to required boolean (boolean or ConstraintDouble) constraints (a boolean constraint is required in advanced constraint sets as you know) and to ideal boolean (boolean or ConstraintDouble) constraints (a boolean constraint is ideal in the basic constraint set as you know).

That should be fixed, I think.
I agree that there is no need to add additional language for the required case.

> I see your point. The phrasing looked very confusing to me. I think we should phrase it differently for extra clarity. Something like `If an ideal value is specified and the settings dictionary cannot support any value for the property, the fitness distance is 1` .
> 
> > Of course, it is possible to remove the step 5 and integrate it in and repeat at steps 7 and 8.
> 
> Now that I see the intent, I think would keep it, but with the rephrasing above (or similar).

Good.

> My summary is that we should:
> 
>    * Eliminate Step 4
>    * Keep the current Step 5, but rephrase it for extra clarity.
>    * Add a step to explain how to compute the fitness distance for (boolean or ConstraintDouble) constraints.
> 
> Do you agree?

Mostly, but I still think that the current step 4 has value for the ideal case.

While at it, I noticed that the current step 6 has probably too low priority.

So would something like below do?

---
 1. If constraintName is not supported by the [User Agent](https://w3c.github.io/mediacapture-main/#dfn-user-agent), the fitness distance is 0.

 2. If the constraint is required (constraintValue either contains one or more members named 'min', 'max', or 'exact', or is itself a bare value and bare values are to be treated as 'exact'), and the [settings dictionary](https://w3c.github.io/mediacapture-main/#dfn-settings-dictionary)'s constraintName member's value does not satisfy the constraint or doesn't [exist](https://infra.spec.whatwg.org/#map-exists), the fitness distance is positive infinity.

 3. If the constraint does not apply for this type of object, the fitness distance is 0 (that is, the constraint does not influence the fitness distance).

 4.  If no ideal value is specified (constraintValue either contains no member named 'ideal', or, if bare values are to be treated as 'ideal', isn't a bare value), the fitness distance is 0.

 5. If constraintValue is a boolean, but the constrainable property is not (the `(boolean or ConstraintDouble)` case), then the fitness distance is based on whether settings dictionary supports any value for the property or not, from the formula

    `(actualSupportForAnyValue == ideal) ? 0 : 1`

 6. If the settings dictionary cannot support any value for the property, the fitness distance is 1.

 7. For all numeric constraints (such as height, width, frameRate, aspectRatio, sampleRate and sampleSize), the fitness distance is the result of the formula

    `(actual == ideal) ? 0 : |actual - ideal| / max(|actual|, |ideal|, |actual - ideal|)`

 8. For all string, enum and boolean constraints (e.g. deviceId, groupId, facingMode, resizeMode, echoCancellation), the fitness distance is the result of the formula

    `(actual == ideal) ? 0 : 1`
---

I used your wording for my step 6 but without `If an ideal value is specified` because that is taken care of by my step 4.

It would be possible to replase my step 5 with a comprehensive `(boolean or ConstrainDouble)` case but that would have to above my step 6 and it would have to repeat my steps 6 and 7, which is suboptimal IMHO.

-- 
GitHub Notification of comment by eehakkin
Please view or discuss this issue at https://github.com/w3c/mediacapture-main/issues/933#issuecomment-1458373126 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Tuesday, 7 March 2023 15:31:43 UTC