Skip to content

Let the server read the platform of web clients - #1336

Draft
hiroshihorie wants to merge 1 commit into
mainfrom
hiroshi/client-info-web
Draft

hiroshihorie wants to merge 1 commit into
mainfrom
hiroshi/client-info-web

Conversation

@hiroshihorie

Copy link
Copy Markdown
Member

Problem

On web, _clientInfo() sent os: defaultTargetPlatform.name. That is the same string native builds send (macOS, iOS, android, windows, linux), so the os field alone can't tell Flutter web on a Mac from native macOS.

The server already parses the User-Agent for FLUTTER clients (AugmentClientInfo in livekit pkg/service/utils.go, both /rtc and /rtc/v1), but it only fills os, os_version, browser, browser_version and device_model when the client left them empty. Because the SDK set os, web clients never got the parsed os and os_version.

Changes

  • Web: send no platform fields, same as client-sdk-js. The server fills all five from the browser User-Agent. Client-side values would also need to match the family names the server checks (isSafari, isFirefox, client configuration rules), which only the server parser produces.
  • Windows: send os_version as major.minor.build (for example 10.0.26100), the same shape the Rust SDK sends. A failed read is logged and does not fail the connect.
  • Linux: device_model was machineId, a unique id of the installation rather than a model. It now reads /sys/class/dmi/id/product_name or /proc/device-tree/model, as the Rust SDK does.
  • Log: Room.connect logs one line naming the SDK version and platform, like the Swift SDK's connect log. For example flutter 2.15.0, macOS 26.2 MacBookPro18,3 or flutter 2.15.0, web, chrome 143.0 on macOS.

Verification

Connected from flutter test --platform chrome to a local livekit-server --dev (1.13.11) and read the clientInfo the server logged.

Before (origin/main):

"os": "android", "deviceModel": "Mac", "browser": "HeadlessChrome", "browserVersion": "159.0.0"

(android because flutter_test sets defaultTargetPlatform to android. In a real browser it is macOS.)

After:

"os": "Mac OS X", "osVersion": "10.15.7", "deviceModel": "Mac", "browser": "HeadlessChrome", "browserVersion": "159.0.0"

Native Flutter's Dart/x (dart:io) User-Agent parses to browser Other, so the server now separates web from native by both os and browser.

Also ran flutter analyze, dart format, import_sorter, check_version and flutter test test/core test/utils_test.dart. I couldn't run the Windows and Linux branches on this machine.

Other SDKs compared

os os_version device_model browser
JS from UA (server) from UA (server) from UA (server) from UA (server)
Swift iOS/macOS/visionOS/tvOS yes utsname / IOKit model none
Android android Build.VERSION.RELEASE MANUFACTURER MODEL none
Rust os_info type os_info version DMI / registry / Build model none
Flutter (this PR) native: explicit, web: from UA (server) yes, web from UA yes except Windows web from UA

Not changed here:

  • Flutter Android sends model only, the Android SDK sends manufacturer model. Aligning them would break continuity in analytics, so it is left for a separate decision.
  • Flutter doesn't set other_sdks. It could report the livekit_ffi core or components-flutter versions.

Follow-ups outside this repo

  • Server ClientInfo.isWebKit() only checks os == ios for JS and Unity WebGL. Flutter web on iOS (Mobile Safari, Chrome Mobile iOS) isn't treated as WebKit, so it gets audio RED and transceiver reuse. That was already the case before this PR. sdk plus os can't separate it from native Flutter iOS, but browser can (native parses to Other).
  • lkBrowser() checks the vendor for Chrome before checking for Edg/, so Edge is detected as chrome. Only the new log line and SDK-internal checks use it, not the client info.

On web the SDK sent os as defaultTargetPlatform.name, which is the same
string native builds send (macOS, iOS, android, windows, linux). The
server fills os, os_version, browser, browser_version and device_model
from the User-Agent only when the client leaves them empty, so web
clients ended up with a native looking os and no os_version. Web now
sends none of them, as the JS SDK does.

Windows now reports os_version (major.minor.build). Linux reported the
machine id, a unique id of the installation, as device_model. It now
reports the hardware model from the firmware tables or the device tree,
as the Rust SDK does.

Room.connect logs one line naming the SDK version and the platform.
@github-actions

github-actions Bot commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

This PR bumps

  • livekit_client: patch

This branch has not been deployed

No deployments
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.

1 participant