Commit 38f9cb0c authored by Shik Chen's avatar Shik Chen Committed by Chromium LUCI CQ

CCA: Ignore setOptions error when tap-to-focus

Some devices do not support the pointsOfInterest control and there is no
standard Web API can query it without trying to apply it.  This CL
catches the exception from applyConstraints() and simply ignores it.

Bug: b/172345418
Test: Manually
Change-Id: Ied24770a1eddf8e6f3772287da6fd55c818b85e6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2637434
Commit-Queue: Shik Chen <shik@chromium.org>
Auto-Submit: Shik Chen <shik@chromium.org>
Reviewed-by: default avatarInker Kuo <inker@chromium.org>
Cr-Commit-Position: refs/heads/master@{#844715}
parent d6dcda1f
...@@ -8,7 +8,7 @@ import("//third_party/closure_compiler/compile_js.gni") ...@@ -8,7 +8,7 @@ import("//third_party/closure_compiler/compile_js.gni")
js_type_check("closure_compile") { js_type_check("closure_compile") {
closure_flags = closure_flags =
default_closure_args + [ default_closure_args + [
"language_in=ECMASCRIPT_2018", "language_in=ECMASCRIPT_2019",
"jscomp_error=lintChecks", "jscomp_error=lintChecks",
"jscomp_error=strictCheckTypes", "jscomp_error=strictCheckTypes",
"conformance_configs=" + "conformance_configs=" +
......
...@@ -470,20 +470,24 @@ export class Preview { ...@@ -470,20 +470,24 @@ export class Preview {
const y = event.offsetY / this.video_.offsetHeight; const y = event.offsetY / this.video_.offsetHeight;
const constraints = {advanced: [{pointsOfInterest: [{x, y}]}]}; const constraints = {advanced: [{pointsOfInterest: [{x, y}]}]};
const track = this.video_.srcObject.getVideoTracks()[0]; const track = this.video_.srcObject.getVideoTracks()[0];
const focus = const focus = (async () => {
track.applyConstraints(constraints) try {
.then(() => { await track.applyConstraints(constraints);
if (focus !== this.focus_) { } catch {
return; // Focus was cancelled. // The device might not support setting pointsOfInterest. Ignore the
} // error and return.
const aim = dom.get('#preview-focus-aim', HTMLObjectElement); return;
const clone = aim.cloneNode(true); }
clone.style.left = `${event.offsetX + this.video_.offsetLeft}px`; if (focus !== this.focus_) {
clone.style.top = `${event.offsetY + this.video_.offsetTop}px`; return; // Focus was cancelled.
clone.hidden = false; }
aim.parentElement.replaceChild(clone, aim); const aim = dom.get('#preview-focus-aim', HTMLObjectElement);
}) const clone = aim.cloneNode(true);
.catch(console.error); clone.style.left = `${event.offsetX + this.video_.offsetLeft}px`;
clone.style.top = `${event.offsetY + this.video_.offsetTop}px`;
clone.hidden = false;
aim.parentElement.replaceChild(clone, aim);
})();
this.focus_ = focus; this.focus_ = focus;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment