fix: ignore incorrect userAgentData in SLBrowser - #1192
Conversation
|
I don't think this is the right workaround. What about gating in Chromium >= 90 in utils.js -- 90 is when this shipped in Chromium according to https://developer.mozilla.org/en-US/docs/Web/API/Navigator/userAgentData cc @miketaylr @yoavweiss who probably have opinions on whether such a modification of userAgentData has wider implications and should be fixed at the source. |
|
@fippo Thanks for the suggestion! I've updated the PR to gate on Chromium >= 90 in utils.js — since navigator.userAgentData itself shipped in Chromium 90, any reported version below that is inherently invalid. This means we now gracefully fall through to UA string parsing in those cases. I've also removed the !description null check in chrome_shim.js since it's no longer needed with this approach. |
|
Thank you @leochliu! Will release a new patch version next week. |
|
The workaround seems sensible here (and whatever SLBrowser is doing, it's just a bug they should fix). |
PR Content
Title
fix: add null check for localDescription to prevent crash on SLBrowser
Description
Problem
Some Chromium-based browsers (e.g. Lenovo SLBrowser) report an incorrect Chromium version in
navigator.userAgentData.brands. For example, SLBrowser reports version9.0.8.3131(its own browser version) instead of the actual Chromium engine version (141).This causes
detectBrowserto return a very low version number (e.g.9), which triggers legacy shim code paths inshimAddTrackRemoveTrack. In this code path,origLocalDescription.get()can returnnullbefore any description is set, and the existing code accesses.typeon it without a null check, resulting in:Reproduction environment:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36 SLBrowser/9.0.8.3131 SLBChan/103 SLBVPV/64-bitChromium/9.0.8.3131, Not?A_Brand/8.0.0.0Fix
Add a null guard for
descriptionbefore accessing.typein thelocalDescriptiongetter withinshimAddTrackRemoveTrack:This is a safe and minimal fix — when
localDescriptionisnull(no local description has been set yet), we simply returnnullas-is, which is the correct WebRTC behavior.Testing
npm run lint-and-unit-tests) continue to pass.