feat: add `app.isHardwareAccelerationEnabled()` by codebytere · Pull Request #47614 · electron/electron · GitHub | Latest TMZ Celebrity News & Gossip | Watch TMZ Live
Skip to content

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

codebytere
Copy link
Member

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 via app.disableHardwareAcceleration().

Checklist

Release Notes

Notes: Added app.isHardwareAccelerationEnabled()

@codebytere codebytere requested a review from a team June 30, 2025 11:00
@codebytere codebytere added semver/minor backwards-compatible functionality api-review/requested 🗳 target/36-x-y PR should also be added to the "36-x-y" branch. target/37-x-y PR should also be added to the "37-x-y" branch. target/38-x-y PR should also be added to the "38-x-y" branch. labels Jun 30, 2025
@codebytere codebytere force-pushed the is-hardware-acceleration-enabled branch from bf13304 to ee82128 Compare June 30, 2025 11:00
@electron-cation electron-cation bot added the new-pr 🌱 PR opened recently label Jun 30, 2025
Copy link
Member

@jkleinsc jkleinsc left a 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;
Copy link
Member

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_;
Copy link
Member

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.
Copy link
Member

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.

electron/docs/api/app.md

Lines 1216 to 1217 in 4f69c58

> [!NOTE]
> This information is only usable after the `gpu-info-update` event is emitted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-review/requested 🗳 new-pr 🌱 PR opened recently semver/minor backwards-compatible functionality target/36-x-y PR should also be added to the "36-x-y" branch. target/37-x-y PR should also be added to the "37-x-y" branch. target/38-x-y PR should also be added to the "38-x-y" branch.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants

TMZ Celebrity News – Breaking Stories, Videos & Gossip

Looking for the latest TMZ celebrity news? You've come to the right place. From shocking Hollywood scandals to exclusive videos, TMZ delivers it all in real time.

Whether it’s a red carpet slip-up, a viral paparazzi moment, or a legal drama involving your favorite stars, TMZ news is always first to break the story. Stay in the loop with daily updates, insider tips, and jaw-dropping photos.

🎥 Watch TMZ Live

TMZ Live brings you daily celebrity news and interviews straight from the TMZ newsroom. Don’t miss a beat—watch now and see what’s trending in Hollywood.