New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 794745 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Last visit > 30 days ago
Closed: Feb 2018
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Chrome
Pri: 1
Type: Bug



Sign in to add a comment

Chrome API setDisplayProperties() doesn't work on recent Chrome OS builds

Project Member Reported by waihong@chromium.org, Dec 13 2017

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.
 
Can anyone update the next steps on this bug, its blocking several tests related to chameleon.
Thanks.
victorhsieh@, do you know who is familiar with the setDisplayProperties() Chrome API? and fix this regression?
I actually don't know.  Maybe ask on chrome-apps-discuss@ ?
Cc: osh...@chromium.org weidongg@chromium.org afakhry@chromium.org
Components: -OS>Kernel>Graphics
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
Components: OS>Kernel>Graphics
Components: -OS>Kernel>Graphics UI>Shell>MultipleMonitor
Are there any logs we can look at?
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.
multimedia_xmlrpc_server.log
173 KB View Download
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.
Attached the logs.
ui.LATEST
3.4 KB Download
chrome
14.6 KB View Download
Did you get these logs right after you ran the steps in the bug description? It doesn't seem so.
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?).
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.
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?
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?
I believe autotest always gets autotestPrivate permission.  But if you want to double check, try printing chrome.runtime.getManifest().permissions in the console.
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?
Cc: rdevlin....@chromium.org
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.
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?
It probably needs to be whitelisted somewhere, but I'm not sure where exactly.
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.
Filed a bug for the whitelist, issue 803543
Project Member

Comment 23 by bugdroid1@chromium.org, 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

Components: -UI>Shell>MultipleMonitor Platform>Extensions>API
Owner: waihong@chromium.org
Status: Assigned (was: Untriaged)
Since you are already working on it.
Status: Fixed (was: Assigned)
Should be fixed. Just need to wait the new Chrome push to Chrome OS.
Status: Assigned (was: Fixed)
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?
Cc: ddavenp...@chromium.org
Cc: cychiang@chromium.org
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.
Filed a separated  issue 810519  for splitting the extension/app.
Status: Fixed (was: Assigned)
Should be fixed. Tested on my local environment.

Sign in to add a comment