Skip to content

fix: ignore incorrect userAgentData in SLBrowser - #1192

Merged
fippo merged 2 commits into
webrtcHacks:mainfrom
leochliu107:fix/null-check-local-description
Jun 7, 2026
Merged

fix: ignore incorrect userAgentData in SLBrowser#1192
fippo merged 2 commits into
webrtcHacks:mainfrom
leochliu107:fix/null-check-local-description

Conversation

@leochliu107

Copy link
Copy Markdown

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 version 9.0.8.3131 (its own browser version) instead of the actual Chromium engine version (141).

This causes detectBrowser to return a very low version number (e.g. 9), which triggers legacy shim code paths in shimAddTrackRemoveTrack. In this code path, origLocalDescription.get() can return null before any description is set, and the existing code accesses .type on it without a null check, resulting in:

TypeError: Cannot read properties of null (reading 'type')

Reproduction environment:

  • Browser: SLBrowser/9.0.8.3131 (Chromium 141) — download: https://browser.lenovo.com.cn/
  • UA: 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-bit
  • UAData brands: Chromium/9.0.8.3131, Not?A_Brand/8.0.0.0

Fix

Add a null guard for description before accessing .type in the localDescription getter within shimAddTrackRemoveTrack:

// Before
if (description.type === '') {

// After
if (!description || description.type === '') {

This is a safe and minimal fix — when localDescription is null (no local description has been set yet), we simply return null as-is, which is the correct WebRTC behavior.

Testing

  • Verified that existing unit tests (npm run lint-and-unit-tests) continue to pass.
  • Manually confirmed the fix resolves the crash on SLBrowser.

@fippo

fippo commented Jun 3, 2026

Copy link
Copy Markdown
Member

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.

@leochliu107

Copy link
Copy Markdown
Author

@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.

@fippo fippo changed the title fix: add null check for localDescription to prevent crash on SLBrowser fix: ignore incorrect userAgentData in SLBrowser Jun 7, 2026
@fippo
fippo merged commit 0d50478 into webrtcHacks:main Jun 7, 2026
7 checks passed
@fippo

fippo commented Jun 7, 2026

Copy link
Copy Markdown
Member

Thank you @leochliu! Will release a new patch version next week.

@miketaylr

Copy link
Copy Markdown

The workaround seems sensible here (and whatever SLBrowser is doing, it's just a bug they should fix).

@fippo fippo mentioned this pull request Jun 15, 2026
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.

4 participants