-
Notifications
You must be signed in to change notification settings - Fork 5
Description
Hi there! 👋
I noticed that there's a bug where Chrome on iOS is being incorrectly identified as Safari 11, causing unnecessary polyfills to be loaded for modern browsers. Chrome on iOS is being misclassified as Safari 11 due to the order of user agent detection logic in useragent.rs
, which results in loading excessive polyfills for modern browsers that don't need them, potentially causing production issues. We observe problem with react-router
redirect
because of loading AbortController
polyfill.
Root Cause
In library/src/useragent.rs
, the detection logic uses if-else statements where:
- Lines 46-200: Mobile Safari detection uses regex
(iPod|iPhone|iPad).+AppleWebKit\/605\.1(?:\.\d+|)
- Line 2180: Correct Chrome mobile detection logic
The Safari regex incorrectly matches Chrome on iOS user agents, preventing the correct Chrome detection from running.
Example Problematic User Agent
Mozilla/5.0 (iPhone; CPU iPhone OS 18_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/92.0.4515.90 Mobile/15E148 Safari/604.1
According to documentation, the difference between Chrome and Safari user agents on iOS is minimal, but this case should be handled correctly.
Current Impact
- Chrome on iOS (modern versions) receives polyfills intended for Safari 11
- Can cause runtime errors in production environments
- Affects performance due to loading unneeded code
Expected Behavior
Chrome on iOS should be correctly identified with its actual version number and receive appropriate polyfills for that version.
Reproduction Steps
- Use Chrome on iOS User Agent
- Request polyfills from the service
- Observe that polyfills for Safari 11 are returned instead of Chrome-appropriate polyfills