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

Samsung device variant user agent strings often fail to precisely match DPDB entry #332

Closed
naftalibeder opened this issue Jul 28, 2018 · 10 comments · Fixed by immersive-web/cardboard-vr-display#30

Comments

@naftalibeder
Copy link

naftalibeder commented Jul 28, 2018

Per issue 37 in the DPDB repo, Samsung devices in particular seem to generate a large variety of user agent string suffixes, which makes it likely an arbitrary device will fail to match against the database entry, even if the hardware model's specs are available.

As marshworks suggested in the above issue, it looks like omitting the trailing character (and the following digit, if any) at the end of the string, when executing matchRule_(), would still produce a 1:1 map of hardware to spec.

So, if given the user agent SM-G950U1 for the Samsung Galaxy S8, the polyfill would only check SM-G950, which would correctly match SM-G950F in the database.

Would this have any repercussions I'm not considering? It would solve what seems to be a pretty common problem.

@jsantell
Copy link
Contributor

I like this idea. We could just alter this line in CardboardVRDisplay to be more lenient for Samsung devices specifically, or modify the current DPDB data. I'm not terribly familiar with the Samsung UA naming convention, but seems like it'd be safer to update the cardboard-vr-display matchRule_() to special case Samsung SM-* devices.

@jsantell
Copy link
Contributor

Samsung would benefit from a special case of handling their multiple resolutions as well, so it wouldn't be out of question to have the cardboard-vr-display special case Samsung UA's.

Related issue: immersive-web/webvr-polyfill-dpdb#37

@jsantell
Copy link
Contributor

Oops, the above issue seems identical to this request; the multiple resolution issue is here: immersive-web/cardboard-vr-display#7

(the downside of having 4 interconnected repos)

@naftalibeder
Copy link
Author

could just alter this line in CardboardVRDisplay to be more lenient for Samsung devices specifically

I agree that that's safer than adding DPDB entries - it seems best to have a prototypical entry for each Samsung hardware model. By way of example, just the variants of the Galaxy S8 hardware outnumber the stars:

SM-G950A
SM-G950T
SM-G950P
SM-G950R4
SM-G950V
SM-G950W8
SM-G950F
SM-G950FD
SM-G950L
SM-G950K
SM-G950S
SM-G9500
SM-G9508
SM-G9509

But it's clear the common prefix for a hardware model is SM-**** So a solution could be:

  1. Catch any ua string starting with SM-.
  2. Match the next 4 characters, e.g. G950, to a genericized DPDB entry (e.g. below).
S7: SM-G930
S7+: SM-G935
S8: SM-G950
S8+: SM-G955
  1. Profit!

Thoughts?

@naftalibeder
Copy link
Author

naftalibeder commented Jul 31, 2018

@jsantell Okay, two options, both tested and working great on my Galaxy S8:

  1. Edit matchRule_() to genericize the ua string of the rule being checked:
if (!rule.ua && !rule.res) return false;
if (rule.ua && rule.ua.substring(0, 2) === 'SM') rule.ua = rule.ua.substring(0, 7);  // add this line
if (rule.ua && ua.indexOf(rule.ua) < 0) return false;

2: Genericize the DPDB entry for all Samsung devices, e.g.:
Current: {"ua":"SM-G950F"}
New: {"ua":"SM-G950"}

I'd vote for 1, because 2 relies on every entry in the database following this (rather unintuitive) pattern. With 1, anytime we find a device with strange naming, we can catch the entire class of devices in a single line.

@jsantell
Copy link
Contributor

jsantell commented Aug 3, 2018

@naftalibeder looks good to me! Do you want to send a PR to cardboard-vr-display, or I can check it out?

I've been looking at general Samsung device model schemes (https://forum.xda-developers.com/wiki/Samsung/Model_naming_scheme, https://en.wikipedia.org/wiki/Samsung_Galaxy#Model_numbers) to see about other Samsung devices that would benefit from this as well, but think the SM line is most likely to be doing VR (GT line looks discontinued in 2013).

@JacobHegwood
Copy link

This is still an issue.

@naftalibeder
Copy link
Author

@jsantell I'm sorry, I forgot to reply to this! Would you mind doing the update with that line if you get a chance?

@JacobHegwood In the meantime you can add the line noted in my comment above to your code locally. Also note that Samsung devices need to be set to the highest resolution in order to be detected, per this issue.

@jsantell
Copy link
Contributor

jsantell commented Sep 8, 2018

@naftalibeder thanks for the update! i'll start pushing the changes upstream over the next few days

@JacobHegwood
Copy link

Yes, I can confirm this is a fix. I ran it on my server and it works just fine for galaxy s8.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants