Chrome API setDisplayProperties() doesn't work on recent Chrome OS builds |
|||||||||||
Issue description
We uses the API setDisplayProperties() to set resolution of external screen and set rotation. Seems that it doens't work on the recent builds. The test display_ResolutionList.extended has been failed for a while due to this bug.
To trigger this function, one can start the xmlrpc server and call the RPCs, like:
(dut) # /usr/local/autotest/cros/multimedia/multimedia_xmlrpc_server.py
Open another terminal
(dut) # python
>>> import xmlrpclib
>>> c = xmlrpclib.ServerProxy('http://localhost:9991')
>>> c.browser.start_default_chrome()
True
>>> eid = c.display.get_first_external_display_id()
>>> c.display.get_available_resolutions(eid)
[[1152, 864], [1280, 720], [720, 400], [1280, 1024], [800, 600], [1920, 1080], [720, 480], [1024, 768], [832, 624], [720, 576], [640, 480], [1080, 607]]
>>> c.display.set_resolution(eid, 1280, 720)
(doesn't change the resolution)
>>> c.display.set_display_rotation(eid, 90)
(doesn't change the rotation)
+kalin@ and rjahagir@ to see any idea when the display_ResolutionList.extended started failing.
,
Jan 9 2018
victorhsieh@, do you know who is familiar with the setDisplayProperties() Chrome API? and fix this regression?
,
Jan 9 2018
I actually don't know. Maybe ask on chrome-apps-discuss@ ?
,
Jan 10 2018
Added the more people who may be able to triage this issue. This is the code to call the Chrome setDisplayProperties API. https://chromium.googlesource.com/chromiumos/third_party/autotest/+/master/client/cros/multimedia/display_facade_native.py#199
,
Jan 10 2018
,
Jan 11 2018
Are there any logs we can look at?
,
Jan 11 2018
What logs do you need? How can I get them for you? I attached the xmlrpc server log of running the steps in c#0.
,
Jan 11 2018
Logs from /var/log/ui/ui.LATEST /var/log/chrome/chrome /home/chronos/user/log/chrome You can also file a feedback report after you reproduce the problem. Type this bug number in the feedback description.
,
Jan 11 2018
Attached the logs.
,
Jan 12 2018
Did you get these logs right after you ran the steps in the bug description? It doesn't seem so.
,
Jan 12 2018
Hi afakhry@, Autotest can show these failures and log files. Starting from the test dashboard - https://stainless.corp.google.com/search?view=matrix&row=build&col=board&first_date=20180108&last_date=20180112&suite=chameleon_hdmi_nightly&test=display_ResolutionList.extended I pick the latest failure for peppy at R65-10301.0.0, and logs are https://pantheon.corp.google.com/storage/browser/chromeos-autotest-results/169516967-chromeos-test/chromeos2-row10-rack9-host3/display_ResolutionList.extended/ In the debug/display_ResolutionList.extended.DEBUG log: - the first bad setDisplayProperties() call is at 01/12 00:28:24.891 - the last - at 01/12 00:33:00.823 sysinfo/var/log/chrome/chrome is the last one in https://pantheon.corp.google.com/storage/browser/chromeos-autotest-results/169516967-chromeos-test/chromeos2-row10-rack9-host3/display_ResolutionList.extended/sysinfo/var/log/chrome/ var/log/ui/ui.LATEST is the last in https://pantheon.corp.google.com/storage/browser/chromeos-autotest-results/169516967-chromeos-test/chromeos2-row10-rack9-host3/display_ResolutionList.extended/sysinfo/var/log/ui/
,
Jan 12 2018
I get these logs just after running the steps at c#0. To be more clear, using the UI Chrome setting > Display to change the external monitor resolution worked fine. It failed on using Chrome API to change it. The resolution didn't change after calling the API. Breaking under the code: https://chromium.googlesource.com/chromiumos/third_party/autotest/+/master/client/cros/multimedia/display_facade_native.py#199 window.__set_resolution_progress = null; chrome.system.display.getInfo((info_array) => { var mode; for (var info of info_array) { if (info['id'] == '%(id)s') { for (var m of info['modes']) { if (m['width'] == %(width)d && m['height'] == %(height)d) { window.__set_resolution_progress = "found_mode"; mode = m; break; } } break; } } if (mode === undefined) { console.error('Failed to select the resolution ' + '%(width)dx%(height)d'); window.__set_resolution_progress = "mode not found"; return; } chrome.system.display.setDisplayProperties('%(id)s', {'displayMode': mode}, () => { if (runtime.lastError) { window.__set_resolution_progress = "failed " + runtime.lastError; } else { window.__set_resolution_progress = "succeeded"; } } ); }); Observed that the callback of chrome.system.display.getInfo() is called. But the callback of setDisplayProperties() has never been called. I don't have much idea how to debug it further. By the way, it uses Telemetry to relaunch Chrome with this extension. https://chromium.googlesource.com/chromiumos/third_party/autotest/+/master/client/cros/multimedia/multimedia_test_extension/manifest.json Not sure if the permission is enough (any change recently?).
,
Jan 12 2018
What does runtime.lastError say? These APIs are restricted to kiosk and WebUI on ChromeOS. However, if this is an autotest, then you need the autotest private permission as well.
,
Jan 12 2018
As the callback of setDisplayProperties() has never been called, don't know the value of runtime.lastError inside it. Inside the callback of getInfo(), runtime.lastError is null. Do you know how to get the autotest private permission?
,
Jan 12 2018
I believe like this: https://cs.corp.google.com/chromeos_public/src/third_party/autotest/files/client/common_lib/cros/autotest_private_ext/manifest.json?l=11 But I'm not sure, +victorhsieh@ may know since he added it. Why the callback of setDisplayProperties() wasn't called? Can you open chrome://inspect and see if there are any JS errors from your extension?
,
Jan 12 2018
I believe autotest always gets autotestPrivate permission. But if you want to double check, try printing chrome.runtime.getManifest().permissions in the console.
,
Jan 16 2018
The debugging skills are useful. Found that the extension we used (multimedia_test_extension) missed the autotestPrivate permission and also found some issues on API expressions. Filed a fix: https://chromium-review.googlesource.com/868578 Now it raises a proper chrome.runtime.lastError, that is: "Only kiosk enabled extensions are allowed to use this function." Is anything missing?
,
Jan 16 2018
If you have the "autotestPrivate" permission, then it shouldn't complain about that. See: https://cs.chromium.org/chromium/src/extensions/browser/api/system_display/system_display_api.cc?type=cs&q=SystemDisplayFunction::ShouldRestrictToKioskAndWebUI&l=182 +devlin if he can see something that I cannot.
,
Jan 16 2018
Seems that defining "autotestPrivate" in the manifest.xml is not enough. After adding "autotestPrivate" permission to the multimedia_test_extension, I checked that the chrome.autotestPrivate object is still undefined on the console. While checking the autotest_private_ext, I can see the chrome.autotestPrivate object. So the autotest_private_ext works as expected but the custom multimedia_test_extension doesn't; still doesn't get "autotestPrivate" permission even it is defined in the manifest.xml. Is there some special rule to limit the "autotestPrivate" permission only to the autotest_private_ext?
,
Jan 16 2018
It probably needs to be whitelisted somewhere, but I'm not sure where exactly.
,
Jan 17 2018
We whitelist approved extensions/apps in the features files, e.g. https://chromium.googlesource.com/chromium/src/+/3f2e5a53920172dcd238f4fea91d346153449deb/chrome/common/extensions/api/_permission_features.json#51 Note that these whitelists are controlled. If you need to add a new entry, please file a new restricted bug and cc me on it to discuss more.
,
Jan 18 2018
Filed a bug for the whitelist, issue 803543
,
Jan 19 2018
The following revision refers to this bug: https://chromium.googlesource.com/chromiumos/third_party/autotest/+/0c3d126df96d64ea54cde3905147ad22e3582078 commit 0c3d126df96d64ea54cde3905147ad22e3582078 Author: Wai-Hong Tam <waihong@google.com> Date: Fri Jan 19 01:40:50 2018 multimedia: Enable autotestPrivate permission and fix some API expressions Enable the autotestPrivate permission for the multimedia extension which is loaded for display/audio end-to-end tests. Fix some API expressions: * runtime -> chrome.runtime * log the last error from chrome.runtime.lastError.message BUG= chromium:794745 TEST=Start xmlrpc server and call the RPCs: (dut) # python >>> import xmlrpclib >>> c = xmlrpclib.ServerProxy('http://localhost:9991') >>> c.browser.start_default_chrome() True >>> eid = c.display.get_first_external_display_id() >>> c.display.set_resolution(eid, 1280, 720) 'Traceback (most recent call last):\n File "/usr/local/autotest/cros/multimedia/multimedia_xmlrpc_server.py", line 92, in _dispatch\n return func(*params)\n File "/usr/local/autotest/cros/multimedia/display_facade_native.py", line 261, in set_resolution\n raise RuntimeError(\'Failed to set resolution: %r\' % result)\nRuntimeError: Failed to set resolution: u\'failed: Only kiosk enabled extensions are allowed to use this function.\'\n' Change-Id: I79a306c3074fd7aa44d2f728aea64cda85317466 Reviewed-on: https://chromium-review.googlesource.com/868578 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Wai-Hong Tam <waihong@google.com> Reviewed-by: Ahmed Fakhry <afakhry@chromium.org> Reviewed-by: Kalin Stoyanov <kalin@chromium.org> Reviewed-by: Victor Hsieh <victorhsieh@chromium.org> [modify] https://crrev.com/0c3d126df96d64ea54cde3905147ad22e3582078/client/cros/multimedia/multimedia_test_extension/manifest.json [modify] https://crrev.com/0c3d126df96d64ea54cde3905147ad22e3582078/client/cros/multimedia/display_facade_native.py
,
Jan 19 2018
Since you are already working on it.
,
Jan 25 2018
Should be fixed. Just need to wait the new Chrome push to Chrome OS.
,
Feb 7 2018
The whitelist CL got into the recent Chrome OS. Double-confirmed the extension ID/hash is correct in the whitelist CL. However, it seems not having the "autotestPrivate" permission. In the console, checked that the chrome.autotestPrivate object is still undefined. Checked that chrome.runtime.getManifest().permissions has "autotestPrivate". Any suggestion to debug it?
,
Feb 7 2018
,
Feb 8 2018
Found the cause. It is because the manifest.json defines it as a platform app, since the Chrome audio APIs can only be used in a platform app. But autotestPrivate can only be applied to an extension, not a platform app. https://chromium.googlesource.com/chromiumos/third_party/autotest/+/master/client/cros/multimedia/multimedia_test_extension/manifest.json Probably we need to split this single extension/app into two: one as an extension for display APIs, and one as an app for audio APIs.
,
Feb 8 2018
Filed a separated issue 810519 for splitting the extension/app.
,
Feb 15 2018
Should be fixed. Tested on my local environment. |
|||||||||||
►
Sign in to add a comment |
|||||||||||
Comment 1 by shirishs...@gmail.com
, Jan 9 2018