Closed Bug 1228899 Opened 9 years ago Closed 7 years ago

[Simulator] default orientation for TV profile should be "landscape"

Categories

(Firefox OS Graveyard :: Simulator, defect)

ARM
Gonk (Firefox OS)
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED WONTFIX

People

(Reporter: schien, Unassigned)

References

Details

[STR]
1. install an app with |orientation: default| in app manifest, e.g. Settings app, on TV Gaia profile
2. launch the app

[Expected Behavior]
app launched in landscape mode

[Actual Behavior]
app launched in portrait mode
Gaia app will invoke |screen.mozLockOrientation| and the orientation will be interpreted as "portrait" in GlobalSimulatorScreen.jsm [1].

[1] https://dxr.mozilla.org/mozilla-central/source/b2g/components/GlobalSimulatorScreen.jsm#42
(In reply to Shih-Chiang Chien [:schien] (UTC+8) (use ni? plz) from comment #1)
> Gaia app will invoke |screen.mozLockOrientation| and the orientation will be
> interpreted as "portrait" in GlobalSimulatorScreen.jsm [1].
> 
> [1]
> https://dxr.mozilla.org/mozilla-central/source/b2g/components/
> GlobalSimulatorScreen.jsm#42

System app launches in 'default' mode if it thinks it's running on a real device. Unfortunately, in Gaia we don't have a explicit way to know the actual context (on real device or on simulator), it guesses from comparing window.innerWidth and scrnen.availWidth [1]. Here, the window.innerWidth is the width set by WebIDE, while scrnen.availWidth is a actual available screen width reported by OS. In most cases we are fine; it's not easy to be exactly the same when a Simulator running on a PC. However, it still has chance to be equal or the user can manually set it to equal on WebIDE UI. Then System app will try to lock the screen as 'default' because it thinks it's on a real device. Then according to the logic in comment 1, it will be set to 'portrait' which is wrong on TV build.

To sum up, here are two issues:

1. In system app, we shouldn't guess the context in this way. Or, we shouldn't care which context we are in Gaia, because ideally platform implementation should fill-up the gap of runtime differences.

2. The mock in GlobalSimulatorScreen doesn't fit TV case. We could simply add a #IFDEF flag to fix the problem quickly, or we can design a better way to fake Orientation API like what bug 1080309 was discussed.

Alex, any thought? :)

[1] https://github.com/mozilla-b2g/gaia/blob/master/tv_apps/smart-system/js/orientation_manager.js#L103-L111
Flags: needinfo?(poirot.alex)
See Also: → 1080309
(In reply to Evelyn Hung [:evelyn] from comment #2)
> 1. In system app, we shouldn't guess the context in this way. Or, we
> shouldn't care which context we are in Gaia, because ideally platform
> implementation should fill-up the gap of runtime differences.

+1!!
There shouldn't be any isRealDevice checks for screen computation!
Gaia should obey to what the platform exposes through screen.*

> 
> 2. The mock in GlobalSimulatorScreen doesn't fit TV case. We could simply
> add a #IFDEF flag to fix the problem quickly, or we can design a better way
> to fake Orientation API like what bug 1080309 was discussed.

I would prefer seeing a pref instead of a #ifdef!
Where is GlobalSimulatorScreen wrong for TV?
Flags: needinfo?(poirot.alex)
(In reply to Alexandre Poirot [:ochameau] from comment #3)
> > 2. The mock in GlobalSimulatorScreen doesn't fit TV case. We could simply
> > add a #IFDEF flag to fix the problem quickly, or we can design a better way
> > to fake Orientation API like what bug 1080309 was discussed.
> 
> I would prefer seeing a pref instead of a #ifdef!
> Where is GlobalSimulatorScreen wrong for TV?

There is nothing wrong (nor more wrong for TV) about GlobalSimulatorScreen than itself being another impl of an existing API. Without making this bug depending my proposed approach on bug 1080309 we should just use a pref() or (#ifdef if Evelyn disagrees with Alex) for now.
Or, we could patch screen.js so that it would set GlobalSimulatorScreen.mozOrientation and GlobalSimulatorScreen.screenOrientation to sideways at start-up to landscape value if it detects the window width is bigger than height.
Wait, that I said exactly above was already added in bug 1142080, contrary to comment 1.

https://hg.mozilla.org/mozilla-central/annotate/c690c50b2b543b420803e8192d6e08e06b20e0a3/b2g/chrome/content/screen.js#l137

What width/height are we launching TV simulator to?
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.