Last Comment Bug 1080309 - Landscape support for b2g desktop/mulet
: Landscape support for b2g desktop/mulet
Status: RESOLVED WONTFIX
:
Product: Firefox OS Graveyard
Classification: Graveyard
Component: General (show other bugs)
: unspecified
: x86 Mac OS X
-- normal (vote)
: ---
Assigned To: Nobody; OK to take it and work on it
:
:
Mentors:
: 1092890 1218664 (view as bug list)
Depends on:
Blocks: 1060118 1063740 1068469 1071942 1074033 1078904 1082667 1088427 1115244
  Show dependency treegraph
 
Reported: 2014-10-08 18:25 PDT by Kevin Grandon :kgrandon
Modified: 2018-03-02 13:34 PST (History)
13 users (show)
See Also:
QA Whiteboard:
Iteration: ---
Points: ---


Attachments
B2G desktop - landscape support (74.04 KB, image/png)
2014-10-14 15:42 PDT, Kevin Grandon :kgrandon
no flags Details
Incomplete patch that touches Hal.cpp (6.61 KB, patch)
2015-12-30 22:53 PST, Tim Guan-tin Chien [:timdream] (please needinfo)
no flags Details | Diff | Splinter Review

Description User image Kevin Grandon :kgrandon 2014-10-08 18:25:30 PDT
In order to sufficiently test our features we need to be able to emulate landscape support for b2g desktop while running MarionetteJS tests.

Since these will be running on real devices soon, I would hope that the same API might be able to be used to trigger landscape mode on a real device as well.
Comment 1 User image Kevin Grandon :kgrandon 2014-10-08 18:26:49 PDT
Myk, Fabrice - Would you guys be able to weigh in on what's needed for this? I believe that the simulator can do something similar here, would we be able to reuse the code for b2g desktop?
Comment 2 User image [:fabrice] Fabrice Desré 2014-10-09 12:18:58 PDT
(In reply to Kevin Grandon :kgrandon from comment #1)
> Myk, Fabrice - Would you guys be able to weigh in on what's needed for this?
> I believe that the simulator can do something similar here, would we be able
> to reuse the code for b2g desktop?

Likely, yes. It's just resizing the window, so I guess we won't trigger orientationchange events. Is that important?
Comment 3 User image Kevin Grandon :kgrandon 2014-10-09 13:07:02 PDT
(In reply to Fabrice Desré [:fabrice] from comment #2)
> Likely, yes. It's just resizing the window, so I guess we won't trigger
> orientationchange events. Is that important?

Yes, I don't think a simple resize will do it. We need orientationchange events and CSS orientation psuedo-selectors to work.
Comment 4 User image Kevin Grandon :kgrandon 2014-10-14 10:46:47 PDT
Code for simulator support is here: https://mxr.mozilla.org/mozilla-central/source/b2g/components/GlobalSimulatorScreen.jsm#55
Comment 5 User image Kevin Grandon :kgrandon 2014-10-14 14:54:22 PDT
This is becoming important so I will do some initial investigation. Anyone is welcome to steal this from me in the meantime though.
Comment 6 User image Myk Melez [:myk] [@mykmelez] 2014-10-14 15:13:50 PDT
Erm, sorry for the delay responding!  ochameau and jryans (cc:ed) are better positioned to respond now, as I haven't been hacking on Simulator code lately, but you're looking in the right place; also see desktop.js, where GlobalSimulatorScreen.flipScreen is called in response to UI events:

http://mxr.mozilla.org/mozilla-central/source/b2g/chrome/content/desktop.js#41
http://mxr.mozilla.org/mozilla-central/source/b2g/chrome/content/desktop.js#96
Comment 7 User image J. Ryan Stinnett [:jryans] 2014-10-14 15:26:26 PDT
Alex may have some suggestions on how to best add this, so flagging him for ni?.
Comment 8 User image Kevin Grandon :kgrandon 2014-10-14 15:37:24 PDT
Thanks guys. It turns out that we can execute chrome JS from our tests, so this might not be too bad. It'll be easy for us to add a helper like: 

var chromeClient = client.scope({ context: 'chrome' });
chromeClient.executeScript(function() {
  GlobalSimulatorScreen.flipScreen();
});

This actually works today, but I think we are still missing some events for the system to resize things. I need to dig in to find out exactly what we're missing.
Comment 9 User image Kevin Grandon :kgrandon 2014-10-14 15:42:39 PDT
Created attachment 8505070 [details]
B2G desktop - landscape support
Comment 10 User image Kevin Grandon :kgrandon 2014-10-14 15:45:17 PDT
That's a picture of B2G desktop after calling GlobalSimulatorScreen.flipScreen();. Seems like we're either not getting a resize event, or maybe the portrait/landscape CSS selectors are not yet working.
Comment 11 User image Alexandre Poirot [:ochameau] 2014-10-16 06:40:30 PDT
Hum. Do you get different behavior between calling flipScreen and clicking manually on the rotate button?!!
Here it works fine if I use the buttons...

And given that clicking on the UI just call flipScreen()...
Comment 12 User image John Hu [:johnhu][:johu][:醬糊小弟] 2014-11-02 19:22:03 PST
*** Bug 1092890 has been marked as a duplicate of this bug. ***
Comment 13 User image Kevin Grandon :kgrandon 2015-10-26 20:45:40 PDT
*** Bug 1218664 has been marked as a duplicate of this bug. ***
Comment 14 User image Kevin Grandon :kgrandon 2015-10-26 20:46:44 PDT
I unfortunately haven't had time to look at this. Hope someone can take it soon though!
Comment 15 User image Tim Guan-tin Chien [:timdream] (please needinfo) 2015-10-27 21:28:40 PDT
It looks like GlobalOrientationScreen and OrientationScreen are re-implementation of MozOrientation API in JS, which is deprecated with the landing of bug 1131470, the new API?

Is it possible to instead hook to the actual native code that in responsible of orientation management instead? I don't think we could rely on that since there were no tests landed w/ bug 944443.

(Just thinking aloud here -- maybe it's not doable at all)
Comment 16 User image Tim Guan-tin Chien [:timdream] (please needinfo) 2015-10-27 21:36:16 PDT
Kind of related: bug 826913, bug 992131. It's better if we could share the code with some feature arguably with more users.
Comment 17 User image Tim Guan-tin Chien [:timdream] (please needinfo) 2015-10-27 22:24:05 PDT
(In reply to Tim Guan-tin Chien [:timdream] (please needinfo) from comment #15)
> Is it possible to instead hook to the actual native code that in responsible
> of orientation management instead?

OK. That's a really bad idea. Both old and the new APIs calls Hal.cpp directly, and the actual backend is responsible of keeping and maintaining the orientation lock. For example, [1] is how Gonk do it.

[1] https://dxr.mozilla.org/mozilla-central/source/widget/gonk/OrientationObserver.cpp#262

So in order for B2G Desktop/Mulet to support a fake orientation, we would need to change all of the calls and insert a middle layer that could manage orientation independently; and it's worse for DevTools responsive mode because to work with that the middle layer would need to manage orientation *per window*.

I don't think this is attainable (or worth the effort) if we are only looking at solving the use case on running tests. Unless DevTools team is seriously thinking about working on the feature and help this bug along the way.
Comment 18 User image Tim Guan-tin Chien [:timdream] (please needinfo) 2015-10-27 22:27:35 PDT
BTW I know we are not running Gij on Emulator, but with bug 975359 test scripts can already control the orientation of Emulator.

Maybe it's worthy to think about whether or not to run Gij on Emulator?
Comment 19 User image Kan-Ru Chen [:kanru] (UTC+8) 2015-11-11 22:22:10 PST
(In reply to Tim Guan-tin Chien [:timdream] (OOO Nov 16-26; please needinfo) from comment #17)
> (In reply to Tim Guan-tin Chien [:timdream] (please needinfo) from comment
> #15)
> > Is it possible to instead hook to the actual native code that in responsible
> > of orientation management instead?
> 
> OK. That's a really bad idea. Both old and the new APIs calls Hal.cpp
> directly, and the actual backend is responsible of keeping and maintaining
> the orientation lock. For example, [1] is how Gonk do it.

I think we could fake at the hal level. For example make hal::GetCurrentScreenConfiguration return fake data based on pref.

> [1]
> https://dxr.mozilla.org/mozilla-central/source/widget/gonk/
> OrientationObserver.cpp#262
Comment 20 User image Tim Guan-tin Chien [:timdream] (please needinfo) 2015-11-11 22:28:43 PST
Looks like a nice project to work on after my PTO!
Comment 21 User image Tim Guan-tin Chien [:timdream] (please needinfo) 2015-12-30 20:53:40 PST
Some update on what I've found in trying to achieve comment 19: Here are how content talk to the HAL implementation.

Parent process content <--> DOM APIs <----------------------------------> Hal.cpp <---> (hal_impl)
Content process content <-> DOM APIs <--> Hal.cpp <-> HalSandbox.cpp <-->

There are two implementations of DOM APIs, and more than four HAL implementation in the tree. So intercepting the call in the one and only Hal.cpp on the parent process is our only way to prevent repetition.

The next best place is within the DOM APIs but it would then have to create it's own testing IPC messages...

So far I am trying to insert an ObserverService#NotifyObservers() into hal::LockScreenOrientation, but I have trouble converting dom::ScreenOrientationInternal (an uint32_t) to char16_t that can be sent through observers. Going to ask around for C++ help.
Comment 22 User image Tim Guan-tin Chien [:timdream] (please needinfo) 2015-12-30 22:53:08 PST
Created attachment 8703071 [details] [diff] [review]
Incomplete patch that touches Hal.cpp
Comment 23 User image Tim Guan-tin Chien [:timdream] (please needinfo) 2016-02-01 18:17:49 PST
Base on priority of my work and the project, I can no longer work on this. Feel free to take my patch and carry on...
Comment 24 User image Mantaroh Yoshinaga[:mantaroh] 2016-02-12 00:05:48 PST
Hi tim.

I faced similar problem(bug 1241385).

What is the lack of your patch?
I think that we should take task as follow.
 - remove Simulator.js from b2g.
 - remove the code of calculating orientation from gaia(orientation_manager.js).

Am I right?
Comment 25 User image Tim Guan-tin Chien [:timdream] (please needinfo) 2016-02-14 19:17:56 PST
(In reply to Mantaroh Yoshinaga[:mantaroh] from comment #24)
> Hi tim.
> 
> I faced similar problem(bug 1241385).
> 
> What is the lack of your patch?
> I think that we should take task as follow.
>  - remove Simulator.js from b2g.

I don't really know what this file do, but it should be done in this bug if we have something equivalent to that.

>  - remove the code of calculating orientation from
> gaia(orientation_manager.js).

Yes we should do this in another bug.

> 
> Am I right?
Comment 26 User image BMO Automation 2018-03-02 13:34:47 PST
Firefox OS is not being worked on

Note You need to log in before you can comment on or make changes to this bug.