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

[Proposal] fix(prober): return "not supported" if browser API take too long #1470

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ export interface IProbedMediaConfiguration {
result?: IResultsFromAPI | undefined;
}>;
}
/**
* Value after which we consider the browser API call to have fail it is still hanging.
* We have noticed that some devices hangs indefinitly on `navigator.requestMediaKeySystemAccess`.
*/
const BROWSER_API_TIMEOUT_MS = 30000;

/**
* Probe media capabilities, evaluating capabilities with available browsers
Expand Down Expand Up @@ -101,7 +106,15 @@ function probeMediaConfiguration(
log.debug(error.message);
}
});
promises.push(prom);

const timeoutPromise = new Promise<void>((_resolve, reject) => {
setTimeout(() => {
// API take too long to respond
log.warn(`MediaCapabilitiesProber: API ${browserAPI} take too long to respond`);
reject();
}, BROWSER_API_TIMEOUT_MS);
});
promises.push(Promise.race([prom, timeoutPromise]));
}
}

Expand Down
Loading