Closed Bug 1080309 Opened 10 years ago Closed 6 years ago

Landscape support for b2g desktop/mulet

Categories

(Firefox OS Graveyard :: General, defect)

x86
macOS
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED WONTFIX

People

(Reporter: kgrandon, Unassigned)

References

Details

Attachments

(2 files)

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.
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?
Flags: needinfo?(myk)
Flags: needinfo?(fabrice)
(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?
Flags: needinfo?(fabrice)
(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.
Blocks: 1078904
Blocks: 1063740
Blocks: 1060118
Blocks: 1074033
Blocks: 1068469
Blocks: 1071942
This is becoming important so I will do some initial investigation. Anyone is welcome to steal this from me in the meantime though.
Assignee: nobody → kgrandon
Status: NEW → ASSIGNED
Flags: needinfo?(myk)
Target Milestone: --- → 2.1 S7 (24Oct)
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
Flags: needinfo?(poirot.alex)
Alex may have some suggestions on how to best add this, so flagging him for ni?.
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.
Attached image B2G desktop - landscape support (deleted) —
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.
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()...
Flags: needinfo?(poirot.alex)
Blocks: 1082667
Target Milestone: 2.1 S7 (24Oct) → ---
Blocks: 1088427
Summary: Landscape support for b2g desktop → Landscape support for b2g desktop/mulet
I unfortunately haven't had time to look at this. Hope someone can take it soon though!
Assignee: kevingrandon → nobody
Status: ASSIGNED → NEW
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)
Kind of related: bug 826913, bug 992131. It's better if we could share the code with some feature arguably with more users.
(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.
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?
(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
Looks like a nice project to work on after my PTO!
Assignee: nobody → timdream
Whiteboard: [systemsfe]
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.
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...
Assignee: timdream → nobody
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?
Flags: needinfo?(timdream)
(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?
Flags: needinfo?(timdream)
Firefox OS is not being worked on
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: