-
Notifications
You must be signed in to change notification settings - Fork 16.2k
feat: add app.isHardwareAccelerationEnabled()
#47614
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
base: main
Are you sure you want to change the base?
Conversation
bf13304
to
ee82128
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this API should only return true if hardware acceleration is currently turned off and the dependency on the flag disable_hw_acceleration_ means that it might not be true
} else { | ||
disable_hw_acceleration_ = true; | ||
} | ||
disable_hw_acceleration_ = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This flag is used elsewhere to determine that disabling hw acceleration has been requested:
if (disable_hw_acceleration_) { |
if (content::GpuDataManager::Initialized()) | ||
return content::GpuDataManager::GetInstance() | ||
->HardwareAccelerationEnabled(); | ||
return !disable_hw_acceleration_; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should use this flag to determine if hardware acceleration is enabled - unless we change the meaning to mean that it is intended to be disabled in the future.
@@ -1197,6 +1197,10 @@ Disables hardware acceleration for current app. | |||
|
|||
This method can only be called before app is ready. | |||
|
|||
### `app.isHardwareAccelerationEnabled()` | |||
|
|||
Returns `boolean` - whether hardware acceleration is currently disabled. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to getGPUFeatureStatus
, it may be worth calling out that this data will only be accurate after gpu-info-update
is emitted. I'd also be curious if that'd be true in practice after the initial time its emitted.
Lines 1216 to 1217 in 4f69c58
> [!NOTE] | |
> This information is only usable after the `gpu-info-update` event is emitted. |
Description of Change
This PR adds
app.isHardwareAccelerationEnabled()
, which can be used to determine whether hardware acceleration has been disabled either on the machine or viaapp.disableHardwareAcceleration()
.Checklist
npm test
passesRelease Notes
Notes: Added
app.isHardwareAccelerationEnabled()