FXOS Window management 101

66
FxOS Window Management 101 alive

description

Introduce window management of FirefoxOS.

Transcript of FXOS Window management 101

Page 1: FXOS Window management 101

FxOS Window Management 101

alive

Page 2: FXOS Window management 101

Agenda● Intro● Life cycle mgmt.● Layout mgmt.● Orientation mgmt.● Visibility mgmt.● Animation mgmt.

● App-specific UI● System-wide UI● Child window mgmt.● History mgmt.● Special apps● Resources

Page 3: FXOS Window management 101

FirefoxOS● Re-implementation of a browser

Page 4: FXOS Window management 101

Window Manager● A window manager is system software that

controls the placement and appearance of windows within a windowing system in a graphical user interface.[1]--wikipedia

Page 5: FXOS Window management 101

Window Mgmt in FxOS● Browser API Wrapper● Interaction between apps● App life cycle management● Transition control● Orientation/Layout/Visibility management

Page 6: FXOS Window management 101

Life Cycle ManagementWindow Management

Page 7: FXOS Window management 101

Life cycle mgmt. (I)When an app is launched?● mozApps API (tap icons on homescreen)● system message

○ bluetooth-*, telephony-*, sms, notification,alarm, activity, headset-button

○ System message would tell system app to launch app at background but app itself may launch itself to foreground.

Page 8: FXOS Window management 101

Flow

Page 9: FXOS Window management 101

Life cycle mgmt. (II)How an app isrendered?● launch path● proper mozbrowser

iframe attributes● container / overlay

/ app specific UI

Page 10: FXOS Window management 101

Life cycle mgmt. (III)When an app is killed?● Crash inside an app.● OOM killer kills it.● Closed in Task Manager.● window.close

Page 11: FXOS Window management 101

Life cycle mgmt. (IV)When the iframe of the killed app is removed from DOM tree?● For active app: after performing closing

animation.● For inactive app: removed immediately after

being killed.

Page 12: FXOS Window management 101

Life cycle mgmt. (V)When a killed app is relaunched?● Homescreen: on home button● Experimental: revive the zombie

app with the same url if it isopened from task manager orswiped in from edge gesture.○ No gecko support yet

Page 13: FXOS Window management 101

Life cycle mgmt. (VI)What happens to a termination?● For activity, perform opening the activity

caller.● For popup, perform opening the window.

open caller.● For app, nothing to do.

Page 14: FXOS Window management 101

Layout ManagementWindow Management

Page 15: FXOS Window management 101

● System app never resizes until orientation changes.

● App resized on○ System app resizes.○ Keyboard opening/closing animation ends.○ Statusbar changes.○ window.resizedBy / window.resizeTo○ Software home button toggles.

Layout mgmt. (I)

Page 16: FXOS Window management 101

Layout mgmt. (II)App’s size is affected by● Fullscreen state (manifest.fullscreen)

○ ParentWindow● Keyboard state● AttentionScreen state● Software home button state● Chrome navigation state● Orientation state

Page 17: FXOS Window management 101

App resizing

Fullscreen appNormal app App with keyboard App with Chrome

Page 18: FXOS Window management 101

App resizing (cont.)

Normal app when attention bar is active

App under landscapePopup with keyboard

Page 19: FXOS Window management 101

Window Management

Visibility Management

Page 20: FXOS Window management 101

Visibility mgmt. (I)● System apps goes to background only when

screen is off.● Page visibility is inheritted while parent

iframe is inactive.● Page visibility is an important reference to

○ Audio competing○ Process Proirity○ Rendering

Page 21: FXOS Window management 101

Visibility mgmt. (II)App goes to foreground while:● Opening animation

starts.● Swipe in animation ends.● Lockscreen is unlocked.

App goes to background while:● Closing animation ends.● 3 secs after callscreens

comes. (bug attention-window)

● Screen is off.

Page 22: FXOS Window management 101

Visibility mgmt. (III)Exceptions● Active app with audio of normal channel

playing● Inline web activity caller● window.open(‘’, ‘’, ‘dialog’) opener

Page 23: FXOS Window management 101

Orientation ManagementWindow Management

Page 24: FXOS Window management 101

App Orientation Management

Page 25: FXOS Window management 101

Orientation mgmt. (I)Controlling from app side:1. manifest.orientation2. screen.mozLockOrientation / Unlock

Page 26: FXOS Window management 101

Orientation mgmt. (II)What’s affecting the orientation?1. LockScreen is locked.2. AttentionScreen is opened.3. Active activity requests its own orientation.4. Active popup requests its own orientation.5. Active app requests its own orientation.

Page 27: FXOS Window management 101

Orientation mgmt. (III)orientationchange event occurs upon:● App opening animation ends.● App closing animation begins.

○ Because of homescreen app’s transparency.

orientationchange means resize and reflow!

Page 28: FXOS Window management 101

Orientation mgmt. (IV)Default orientation● System app would try to acquire default

orientation on bootup.○ For tablet it’s landscape-primary○ For mobile it’s portrait-primary

● App could request default orientation in manifest or orientation API.

Page 29: FXOS Window management 101

Orientation mgmt. (V)If the app doesn’t acquire its orientation● If orientation-lock setting is not enabled,

unlock the orientation. (means rotatable)● If orientation-lock setting is enabled, locked

to the default orientation.

Page 30: FXOS Window management 101

Window-Specific UI/UXWindow Management

Page 31: FXOS Window management 101

App specific UI/UX● Modal dialog● Context Menu● Shrinking for NFC● Browser Chrome● Audio channel service (1.5+)

Page 32: FXOS Window management 101

alert/confirm/prompt

Page 33: FXOS Window management 101

Context Menu

Page 34: FXOS Window management 101

● No, Not

● For web pages needs back/forward/refresh functions still.

● Or apps declaring { chrome: { navigation: true } } in manifest.

● Affects the height of the content.

Browser Chrome

Page 35: FXOS Window management 101

Browser Chrome

Page 36: FXOS Window management 101

Shrinking

Page 37: FXOS Window management 101

Window Management

System-Wide UI/UX

Page 38: FXOS Window management 101

System wide UI1. Dialog which not belong to a single app but

needs to fit app layout when some events trigger it.○ Volume warning dialog○ SIM PIN unlock dialog○ Cell Broadcast dialog

2. UI affecting window behavior○ Software home button

Page 39: FXOS Window management 101

Software home button● Hardware home button alternative● Automatically enabled on no-hardware-

button device, e.g., Nexus 4.○ media-query: -moz-physical-home-button

● Affects the size of non-fullscreen app.

Page 40: FXOS Window management 101

Home Gesture● Another hardware home button alternative.

○ While being enabled, swiped from bottom could perform app closing.

● Automatically enabled on tablet.

Page 41: FXOS Window management 101

(CE)Volume warning dialogShow up while all of the following conditions are satiesfied.1. Earphone is plugged.2. Exceeds volume threshold. ( > 85dB)3. Content channel audio is playing.4. First warning or after 20 consecutive hours

while dismissed.

Page 42: FXOS Window management 101

SIM PIN unlock dialogShow up while● The opening app has telephony permission

in manifest○ Blacklist: settings and FTU

● Airplane mode is turned off.

Page 43: FXOS Window management 101

Window Management

Child Windows Management

Page 44: FXOS Window management 101

An app/page has is opened directly or indirectly by other app/page.● Attention window● Popup window● Activity window● Trusted UI / Trusted window

Child window

Page 45: FXOS Window management 101

Child window mgmt.● When a child window terminates normally,

re-open its parent window.● Some sort of child window may also have

another child window.● Process priority management between

parent and child is an issue.

Page 46: FXOS Window management 101

Activity dispositionsInline Activity● Creates a new

reference page to provide the data to the activity.

Window Activity● Reuse the existing

app window to consume the activity data.

Page 47: FXOS Window management 101

Attention Window● Used to get your attention

○ Call screen - dialer○ Alarm screen - clock

● Permission is necessary● Only portrait primary orientation● Non modal for now.

Page 48: FXOS Window management 101

● Persona and mozPay API are using.● Specific sizing: ~80%● Partial visible homescreen during trustedUI

is running.

Trusted UI

Page 49: FXOS Window management 101

Trusted UI - Persona

Page 50: FXOS Window management 101

Window Management

History Management

Page 51: FXOS Window management 101

Task Manager● Reflection of the app history.● Be able to kill an app actively.● Optional: Keep zombie app to pretend it is

still alive.● Future: In app stack reflection.

Page 52: FXOS Window management 101

Edge gesture

Edge Gesture - App to app history view

Page 53: FXOS Window management 101

Edge Gesture - In app history view

Page 54: FXOS Window management 101

Edge gesture● How to decide next app?

a. Child window of the active appb. Launch time is just newer

■ Find the head window of the next app stack● How to decide previous app?

a. Parent window of the active appb. Launch time is just elder

■ Find the rear window of the previous app stack

Page 55: FXOS Window management 101

Task Manager

Page 56: FXOS Window management 101

Screenshoting mgmt.App screenshoting is taken at● App closing animation ends.● Getting into task manager.

Screenshoting is expensive!

Page 57: FXOS Window management 101

App AnimationsWindow Management

Page 58: FXOS Window management 101

State Machine of App Transitions

Page 59: FXOS Window management 101

App Switching Flow

Page 60: FXOS Window management 101

1. Before an app is opening, we need to ensure it’s recovered from background state.○ Tricks: take 1x1 screenshot to enforce redraw.

2. After the app is ready to be opened, perform the opening animation of the next app and the closing animation of the current app at the same time.

App transitions (I)

Page 61: FXOS Window management 101

App transitions (II)● Do screen orientations lock/unlock at

opened and at closing.● Do resizing at opening only if the app is

resized once. Otherwise, skip resizing step.● Do change page visibility under

screenshoting protection.

Page 62: FXOS Window management 101

Special AppsWindow Management

Page 63: FXOS Window management 101

Homescreen● Swappable.

○ Launched via homescreen manifestURL setting.○ Relaunched while the setting is changed in settings

app or while home button is ensured.● Higher process priority than other

background app to avoid quick killing.

Page 64: FXOS Window management 101

FTU (First Time Usage)● Launched via FTU ManifestURL setting.● Only be launched automatically on fresh

flashing.○ make NOFTU=1 to avoid it.

● Way of app switching is disabled while FTU is running.

Page 65: FXOS Window management 101

Other special apps● Keyboard

○ Affect the size of active app window.● Cost control

○ Widget-like iframe inside utility tray.● Secure camera

○ Layout upon lockscreen.● Lockscreen

○ Swappable app in the future.

Page 66: FXOS Window management 101

Resources● Architecture slide

○ http://bit.ly/window-mgmt-slide● JSDOC

○ http://alivedise.github.io/gaia-system-jsdoc/AppWindow.html

● Meta bug○ http://bugzil.la/window-management