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

Remove disable-gpudefault flag for Apple Silicon #421

Closed
thibaudgg opened this issue Nov 27, 2023 · 3 comments · Fixed by #436
Closed

Remove disable-gpudefault flag for Apple Silicon #421

thibaudgg opened this issue Nov 27, 2023 · 3 comments · Fixed by #436

Comments

@thibaudgg
Copy link
Contributor

The disable-gpu is part of the default Chrome options but it is causing issues with webpages using WebGL on Apple Silicon machine.

I was able to make it work by removing the disable-gpu flag and adding the --use-angle=metal flag via this small monkey-patch:

# Enable GPU (with Metal) for Chrome on Apple Silicon
if Gem::Platform.local.cpu == "arm64" && Gem::Platform.local.os == "darwin"
  chrome_class = Ferrum::Browser::Options::Chrome
  default_options = chrome_class::DEFAULT_OPTIONS.dup

  default_options.delete('disable-gpu')
  default_options['use-angle'] = 'metal'

  chrome_class.send(:remove_const, 'DEFAULT_OPTIONS')
  chrome_class::DEFAULT_OPTIONS = default_options.freeze
end

Do you think this should be set by default for Apple Silicon, or at least stop adding the disable-gpu flag on this platform?
I'm happy to provide a PR if needed.

@route
Copy link
Member

route commented Jan 7, 2024

From https://developer.chrome.com/blog/headless-chrome

Do I need the --disable-gpu flag?

Only on Windows. Other platforms no longer require it. The --disable-gpu flag is a temporary work around for a few bugs. You won't need this flag in future versions of Chrome. See crbug.com/737678 for more information.

So you are right, we need to add some conditionals for windows and mac most likely. Mind sending a PR?

thibaudgg added a commit to electric-feel/ferrum that referenced this issue Jan 8, 2024
This patch aims to close the issue rubycdp#421 by doing the following:

1. Only including the `--disable-gpu` flag when running on Windows as it
   is not needed on other platforms and it causes issues on Mac ARM.
2. Adding the `--use-angle=metal` flag when running on Mac ARM so the
   browser uses the Metal API instead of OpenGL.

Close rubycdp#421
@thibaudgg
Copy link
Contributor Author

@route sure things, just created a PR for it: #436

@route route closed this as completed in #436 Jan 8, 2024
route pushed a commit that referenced this issue Jan 8, 2024
This patch aims to close the issue #421 by doing the following:

1. Only including the `--disable-gpu` flag when running on Windows as it
   is not needed on other platforms and it causes issues on Mac ARM.
2. Adding the `--use-angle=metal` flag when running on Mac ARM so the
   browser uses the Metal API instead of OpenGL.

Close #421
@route
Copy link
Member

route commented Jan 8, 2024

Thanks!

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 a pull request may close this issue.

2 participants