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

Deobfuscate Safari 14+ (MacOS) #47

Open
TimvanScherpenzeel opened this issue Oct 16, 2020 · 16 comments
Open

Deobfuscate Safari 14+ (MacOS) #47

TimvanScherpenzeel opened this issue Oct 16, 2020 · 16 comments
Labels
3.2 help wanted Extra attention is needed investigation

Comments

@TimvanScherpenzeel
Copy link
Collaborator

TimvanScherpenzeel commented Oct 16, 2020

Currently Safari 14 obfuscates the renderer string as 'apple gpu' preventing an accurate match.

https://github.com/TimvanScherpenzeel/detect-gpu/blob/de0e8d4695a0a6d8f8dcc424af68714ada2e76f7/src/internal/deobfuscateAppleGPU.ts#L119

A possible solution could be to have a lookup table of possible GPUs iMacs and Macbooks can have and matching on that with extra metadata (devicePixelRatio, screenSize, user agent).

Open for any suggestions / PR's 😃

@TimvanScherpenzeel TimvanScherpenzeel added help wanted Extra attention is needed investigation labels Oct 16, 2020
@bastienrobert
Copy link
Contributor

This article is about GPU detection of iPhones using the floating point precision. It works for iPhone 7 vs iPhone 8 and +. Maybe we could investigate to get more precision?

@TimvanScherpenzeel
Copy link
Collaborator Author

TimvanScherpenzeel commented Oct 16, 2020

@bastienrobert we are currently using an optimised version of that in https://github.com/TimvanScherpenzeel/detect-gpu/blob/9b2b19726499439b545c084a569a16300ab2de7f/src/internal/deobfuscateAppleGPU.ts#L19-L118.

Some earlier research for handling iOS 12.2+ iPhones / iPads specifically was done in #7.

It could be worth testing to see if we can get different floating point numbers on different Mac GPU's.

@TimvanScherpenzeel
Copy link
Collaborator Author

TimvanScherpenzeel commented Oct 16, 2020

I think it is safe to say Safari only runs on Mac devices. From https://gfxbench.com/result.jsp I was able to gather the following list of possible GPU's (I'll update this comment with more data related to the specific devices).

https://gfxbench.com/result.jsp?benchmark=gfx50&test=757&order=median&text-filter=apple&base=device&os-check-Android_gl=0&os-check-Android_vulkan=0&os-check-iOS_gl=0&os-check-iOS_metal=0&os-check-Linux_gl=0&os-check-Windows_dx=0&os-check-Windows_dx12=0&os-check-Windows_gl=0&os-check-Windows_vulkan=0&arch-check-ARM=0&arch-check-unknown=0&ff-check-lmobile=0&ff-check-smobile=0

// https://support.apple.com/nl-nl/HT202471
// 16-inch MacBook Pro: 3072x1920 (226 pixels / inch)
// 15-inch Macbook Pro: 2880x1800 (220 pixels / inch)
// 13-inch Macbook Pro: 2560x1600 (227 pixels / inch)
// MacBook Air: 2560x1600 (227 pixels / inch)
// MacBook: 2304x1440 (226 pixels / inch)
// 27-inch iMac: 5120x2880
// 21.5-inch iMac: 4096x2304, 1920x1080
// iMac Pro: 5120x2880
Apple iMac (21.5-inch, Late 2012) - NVIDIA GeForce GT 640M Mac Edition - (1920x1080)
Apple iMac (21.5-inch, Late 2012) - NVIDIA GeForce GT 650M Mac Edition - (1920x1080)
Apple iMac (21.5-inch, Mid 2014) - Intel® HD Graphics 5000 - (1920x1080)
Apple iMac (21.5-inch, Now) - Intel Iris Plus Graphics 640 - (1920x1080)
Apple iMac (27-inch, Late 2012) - NVIDIA GeForce GTX 675MX Mac Edition - (2560x1600)
Apple iMac (27-inch, Late 2012) - NVIDIA GeForce GTX 680MX - (2560x1600)
Apple iMac (27-inch, Late 2013) - NVIDIA GeForce GT 755M Mac Edition - (2560x1600)
Apple iMac (Retina 5K, 27-inch, Late 2014/Mid 2015) - AMD Radeon R9 M290 - (5120x2880)
Apple iMac (Retina 5K, 27-inch, Late 2015) - AMD Radeon R9 M395 - (5120x2880)
Apple iMac (Retina 4K, 21.5-inch, Now) - Radeon Pro 555X - (4096x2304)
Apple iMac (Retina 4K, 21.5-inch, Now) - Radeon Pro 560X - (4096x2304)
Apple iMac (Retina 4K, 21.5-inch, Now) - Radeon Pro Vega 20 - (4096x2304)
Apple iMac (Retina 5K, 27-inch, Now) - Radeon Pro 5300 - (5120x2880)
Apple iMac (Retina 5K, 27-inch, Now) - Radeon Pro 5500 XT - (5120x2880)
Apple iMac (Retina 5K, 27-inch, Now) - Radeon Pro 5700 - (5120x2880)
Apple iMac (Retina 5K, 27-inch, Now) - Radeon Pro 5700 XT - (5120x2880)

Apple iMac Pro (Retina 5K, 27-inch, Late 2017) - AMD Radeon Pro Vega 56 - (5120x2880)
Apple iMac Pro (Retina 5K, 27-inch, Late 2017) - AMD Radeon Pro Vega 64 - (5120x2880)
Apple iMac Pro (Retina 5K, 27-inch, Late 2017) - AMD Radeon Pro Vega 64X - (5120x2880)

Apple Mac mini (Late 2014) - Intel® Iris - (?)
Apple Mac mini (Now) - Intel UHD Graphics 630 - (?)

Apple Mac Pro (Late 2013) - AMD FirePro D300 - (?)
Apple Mac Pro (Late 2013) - AMD FirePro D500 - (?)
Apple Mac Pro (Late 2013) - AMD FirePro D700 - (?)
Apple Mac Pro (Now) - AMD Radeon Pro 580X - (?)
Apple Mac Pro (Now) - AMD Radeon Pro W5500X - (?)
Apple Mac Pro (Now) - AMD Radeon Pro W5700X - (?)
Apple Mac Pro (Now) - AMD Radeon Pro Vega II - (?)
Apple Mac Pro (Now) - AMD Radeon Pro Vega II Duo - (?)

Apple MacBook (Retina, 12-inch, Early 2015) - Intel® HD Graphics 5300 - (2304x1440)

Apple MacBook Air (11-inch, Early 2015) - Intel® HD Graphics 6000 - (1366x768)
Apple MacBook Air (11-inch, Mid 2012) - Intel® HD Graphics 4000 - (1366x768)
Apple MacBook Air (11-inch, Mid 2013/Early 2014) - Intel® HD Graphics 5000 - (1366x768)
Apple MacBook Air (13-inch, Early 2015) - Intel® HD Graphics 6000 - (1440x900)
Apple MacBook Air (13-inch, Mid 2012) - Intel® HD Graphics 4000 - (1440x900)
Apple MacBook Air (13-inch, Mid 2013/Early 2014) - Intel® HD Graphics 5000 - (1440x900)
Apple MacBook Air (13-inch, Now) - Intel Iris Plus Graphics - (2560x1600)

Apple MacBook Pro (Retina, 13-inch, Late 2013/Mid 2014) - Intel® Iris - (2560x1600)
Apple MacBook Pro (Retina, 13-inch, Late 2013/Mid 2014) - Intel® Iris Graphics 6100 - (2560x1600)
Apple MacBook Pro (Retina, 13-inch, Late 2016) - Intel® Iris Graphics 540 - (2560x1600)
Apple MacBook Pro (Retina, 13-inch, Now) - Intel Iris Plus Graphics 645 - (2560x1600)
Apple MacBook Pro (Retina, 13-inch, Now) - Intel Iris Plus Graphics - (2560x1600)
Apple MacBook Pro (Retina, 15-inch, Late 2013/Mid 2014) - Intel® Iris™ Pro Graphics 5200 - (2880x1800)
Apple MacBook Pro (Retina, 15-inch, Late 2013/Mid 2014) - NVIDIA GeForce GT 750M Mac Edition - (2880x1800)
Apple MacBook Pro (Retina, 15-inch, Mid 2012/Early 2013) - Intel® HD Graphics 4000 - (2880x1800)
Apple MacBook Pro (Retina, 15-inch, Mid 2012/Early 2013) - NVIDIA GeForce GT 650M Mac Edition - (2880x1800)
Apple MacBook Pro (Retina, 15-inch, Mid 2015) - AMD Radeon R9 M370X - (2880x1800)
Apple MacBook Pro (Retina, 15-inch, Mid 2015) - Intel® Iris™ Pro Graphics 5200 - (2880x1800)
Apple MacBook Pro (Retina, 16-inch, Now) - AMD Radeon Pro 5300M - (3072x1920)
Apple MacBook Pro (Retina, 16-inch, Now) - AMD Radeon Pro 5500M - (3072x1920)
Apple MacBook Pro (Retina, 16-inch, Now) - AMD Radeon Pro 5600M - (3072x1920)

@bastienrobert
Copy link
Contributor

Agree with that

@TimvanScherpenzeel
Copy link
Collaborator Author

Sadly it appears that the benchmark data we use from gfxbench is quite outdated and Apple has been using a plethora of different GPUs over the years.

I think we can do some preliminary boxing of categories based on the screen size but at this point in time I don't see a feasible way to reasonably accurately determine the GPU.

Another challenge is that even if we are able to narrow down the scope it will be very hard to evaluate our implementation because you will need access to physical devices (Browserstack does that with mobile devices and tablets but desktops are virtualised).

This is one of the reasons why I prefer using detect-gpu for setting defaults in the application so that a user can pick the rendering quality themselves.

I'll leave this ticket open for now, any ideas are welcome :)

@TimvanScherpenzeel TimvanScherpenzeel added 3.1 and removed 2.1 labels Jun 7, 2021
@TimvanScherpenzeel TimvanScherpenzeel removed their assignment Jun 7, 2021
@TimvanScherpenzeel TimvanScherpenzeel changed the title Investigation: deobfuscate Safari 14 Investigation: deobfuscate Safari 14+ (iOS + MacOS) Jun 14, 2021
@Gusted
Copy link
Contributor

Gusted commented Jun 14, 2021

iPhone 12 Pro Max gets recognized as iPhone 11 Pro Max (both have the same screen size - not much we can do there)

Is safari manipulating the screen dimensions? Iphone 11 pro max has a 6,5 inch screen(2688x1242) and the Iphone 12 pro max has a 6,7 inch screen(2778x1284). Otherwise you could reliably* detect those 2 apart.

@TimvanScherpenzeel
Copy link
Collaborator Author

Interesting, the benchmark data reports both as having 2688x1242, could be something funky going on there.

  [
    "apple a13 gpu",
    "13",
    0,
    [
      [2688, 1242, 60, "apple iphone 11 pro max"]
    ]
  ],
  [
    "apple a14 gpu",
    "14",
    0,
    [
      [2688, 1242, 60, "apple iphone 12 pro max"],
    ]
  ],

@TimvanScherpenzeel
Copy link
Collaborator Author

Ah.. wait a second, this is because of recent change where we include internalBenchMarkResults.ts, the resolution has been reported wrongly there:

{
date: '2021.01.29',
device: 'Apple iPhone 12 Pro Max',
fps: 60,
gpu: 'Apple A14 GPU',
mobile: true,
resolution: '2688 x 1242',
},

@Gusted
Copy link
Contributor

Gusted commented Jun 14, 2021

the resolution has been reported wrongly there:

Aha, phew 😅 Safari isn't faking screen dimensions.

@Gusted
Copy link
Contributor

Gusted commented Jun 14, 2021

And that issue should be fixed now in 3.1.2 nice job! 🎈

@TimvanScherpenzeel
Copy link
Collaborator Author

And that issue should be fixed now in 3.1.2 nice job! 🎈

Fixed in 3.1.3, I had mistakingly not ran yarn build after bumping the version making it so that it was still pointing to the old benchmarks.

@CaelanStewart
Copy link

@TimvanScherpenzeel

I'm seeing a problem in Safari 15 (Technology Preview Release 127) on macOS 11.4 on an iMac with an AMD Radeon Pro 580 8GB GPU.

The demo page (which appears to be loading the latest 3.1.9 release) incorrectly identifies the tier of this GPU:

{
  "gpu": "apple gpu (Apple GPU)",
  "isMobile": false,
  "tier": 1,
  "type": "FALLBACK"
}

On Chrome and Firefox, however, it is identified correctly:

{
  "fps": 50,
  "gpu": "amd radeon pro 580 opengl engine",
  "isMobile": false,
  "tier": 2,
  "type": "BENCHMARK"
}

Let me know if there's anything I can do to help or any tests I can run.

@CaelanStewart
Copy link

CaelanStewart commented Jul 19, 2021

@TimvanScherpenzeel – Apologies, I misread your last comment to indicate that you'd fixed this problem in Safari 14.

I see this is still an ongoing issue.

Happy to help by running any tests.

@TimvanScherpenzeel
Copy link
Collaborator Author

Hi @CaelanStewart, you are correct that this is an open problem due to the obfuscation that Apple does.
If you are able to expand the list I posted above here with more recent devices (GPU, device resolution) that would be helpful.
Any new ideas of how we could deobfscate the GPU are welcome because we are at a bit of a dead end due to the large target base with very similar resolutions.

@TimvanScherpenzeel TimvanScherpenzeel changed the title Investigation: deobfuscate Safari 14+ (iOS + MacOS) Deobfuscate Safari 14+ (iOS + MacOS) Jul 20, 2021
@TimvanScherpenzeel TimvanScherpenzeel changed the title Deobfuscate Safari 14+ (iOS + MacOS) Deobfuscate Safari 14+ (MacOS) Jul 20, 2021
@puckey
Copy link
Collaborator

puckey commented Dec 17, 2021

we could probably get quite far by detecting different models of apple laptops based on screen resolutions.. unless they are connected to an external display that is

@lassemt
Copy link

lassemt commented Jan 24, 2022

@TimvanScherpenzeel I noticed you mentioned Active Theory's solution in #7 and mentioned it's a hacky way (I agree), but I want to point to their solution is based on 51Degrees/Renderer in case it helps. They do exactly the same but have excluded the CPU Benchmarking from their code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.2 help wanted Extra attention is needed investigation
Projects
None yet
Development

No branches or pull requests

6 participants