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
Add app.getGPUFeatureStatus #9623
Conversation
@kevinsawicki, should I name it |
I'm thinking |
@kevinsawicki renamed & added docs. |
atom/browser/api/atom_api_app.cc
Outdated
mate::Dictionary App::GetGPUFeatureStatus(v8::Isolate* isolate) { | ||
auto result = mate::Dictionary::CreateEmpty(isolate); | ||
|
||
if (auto status = content::GetFeatureStatus()) { |
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.
There should already be a converter setup for base::DictionaryValue
.
Would this work here?
return mate::ConvertToV8(isolate, status);
Then you wouldn't need the ConvertDictionary
helper.
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'll try that
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.
It does not work. There does not seem to be a converter from base::DictionaryValue
. In generic case the values can have different types. In this case it can only be a string.
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.
@miniak I pushed up a spec and commit that uses the converter, please let me know if you are okay with that approach.
atom/browser/api/atom_api_app.cc
Outdated
@@ -1095,7 +1126,8 @@ void App::BuildPrototype( | |||
.SetMethod("getFileIcon", &App::GetFileIcon) | |||
.SetMethod("getAppMetrics", &App::GetAppMetrics) | |||
// TODO(juturu): Remove in 2.0, deprecate before then with warnings | |||
.SetMethod("getAppMemoryInfo", &App::GetAppMetrics); | |||
.SetMethod("getAppMemoryInfo", &App::GetAppMetrics) | |||
.SetMethod("getGPUFeatureStatus", &App::GetGPUFeatureStatus); |
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.
Mind moving this above the // TODO
comment so we don't think it is marked for deprecation like getAppMemoryInfo
is?
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.
done
spec/api-app-spec.js
Outdated
@@ -558,4 +558,14 @@ describe('app module', function () { | |||
assert.ok(types.includes('Tab')) | |||
}) | |||
}) | |||
|
|||
describe('getGPUFeatureStatus() API', function () { | |||
if (process.platform !== 'darwin') return |
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.
@kevinsawicki Do we need to check for Mac? It should work on all platforms.
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.
Okay, wasn't sure, will remove this line 👍
Thanks for this @miniak 👍 |
@kevinsawicki thanks for merging |
This method returns the Graphics Feature Status from chrome://gpu/ as JSON.
It allows detecting the status of GPU acceleration without having to open a hidden
BrowserWindow
and parsing the data from HTML.Example output:
The list of possible values can be found in
chrome://gpu/gpu_internals.js
(statusMap
).