SlideShare a Scribd company logo
1 of 72
Architecture, Development, Patterns
Window Manager
A core module in an operating system, which is
responsible to display and maintain the window
based UI.
Window Mgmt. at FxOS
● A clustor of modules mainly serves to create
web apps.
● A re-implementation of a browser.
● Ability to handle WebAPI request between
apps.
Things inside..
Window Manager (v1.3-)
Modal
Dialog
Truste
UI
AuthDi
alog
transition control
create
mozbrowser
iframe maintain app life
cycle
gen screenshots
redirect
mozbrowser
events
orientation
control
layout control
error handling
visibility control
web activities
management
web app
management
manage
homescreen
manage ftu
It’s sad to have a such giant module to
control everything :(
The secret to build a large app ?
The secret to build a large app ?
Never build a large app
Solutions
Instances +
Manager +
Scalable Patterns
INSTANCES
Minimal operable unit
AppWindow
● The basic unit which wraps the mozbrowser
iframe.
● (Mostly) Standalone library to create a
webapp instance.
● Each appWindow instance maintains its own
states and display proper UI according to
these states.
Extra chrome UI
Real web content
AppWindow States
● Visibility: |document.hidden|
● Orientation: screen.orientation
● Layout: window.innerHeight/innerWidth
● Transition
● Loading
● Title, icon, ….
App Visibility
● Active app is basically foreground, but we
are having some more complex rules; for
instance, a chaining activities are all
foreground.
● Page visibility is particially impacting the
process priority.
● The timing of visibilitychange was bind to
transition states.
App Orientation
● Passive orientation requested in manifest
● Active orientation requested by
screen.lockOrientation()
o System app does not being involed too
much in this progress but is expected to.
o What if lock orientation during
transitioning?
● Query by screen.mozOrientation
App has no knowledge about (x, y),
but (w, h) is affecting app by window.innerHeight,
window.innerWidth, and reflow/resize if that changed.
Layout = (x, y,
w, h)
Use small piece of codes
doing limited tasks
AppWindow: Submodule
To avoid a giant AppWindow class..
AppWindow Submodules
AppWindow
Each submodule is responsible to handle a specific request
from the appWindow. Their only dependency is the
appWindow who launches/instantiates them.
M
M
M
M
M
MHW
M
M
M
M
M M
At
W
M
M
M
M
M
M
submodule
Current
Submodules
AppWindow
ModalDialog
AuthenticationDialog
TransitionController
Chrome
ContextMenu
childWindowFactory
window.alert
window.open
HTTP Auth
chrome property
<contextmenu>
Transition State Machine
<iframe mozBrowser>
Developing Submodules
var MyModule = function(app) {
this.app = app;
this.app.element.addEventListener(‘_opened’, this);
};
MyModule.prototype = {
handleEvent: function() {
// ...
}
};
AppWindow.SUB_MODULES = {
‘myModule’: window.MyModule
};
var a = new AppWindow();
typeof(a.myModule) // === MyModule
Transition Finite State Machine
● A submodule to process transition related
events to maintain the state and perform the
transition.
● States: opened/opening/closed/closing
● Transition state should be standalone from
other states.
openedclosed
opening
closing
AppWindow
AppWindow does not care the state maintainence, but
only ask the finite state machine to process events
openedclosed
opening
closing
AppWindow
Whenever state is changed, transition FSM will
publish events for the app.
Interactions between AppWindows..
We are living in a world of multiple apps. An
appWindow should not do anything it wants to
do.
Request before permitted!
MANAGERS
Managing multiple standalone instances
If all the subordinates are standalone
The job of a manager is easy!
Manager
● Lifecycle Management
● Hierarchy Management
LifeCycle Management
● Maintain a list of alive windows
● Manage the interaction between window
instances
● Events happens inside an appWindow is
delegated to the appWindow itself.
● Interactions involved multiple appWindows
needs the manager to decide what to do.
Life cycle - launch
● AppWindowManager has an appWindow
factory to deal with launch request from the
gecko(system message) or the user.
● Each AppWindow instances has a child
window factory to deal with launch request
from the app.
AppWindowManager
#AppWindow
Gecko
webapps-launch open-app
Factory
Factory
mozbrowseropenwindow
launchactivity
#AppWindow
Factor
y
#AppWindow
Factor
y
#AppWindow
Factor
y
#AppWindow
Factor
y #PopupWindow
Factor
y
#ActivityWindow
Factor
y
#AttentionWindow
appopenwindow
Life cycle - kill
● active kill
o window.close()
o ParentWindow is killed
o The user kills it from task manager.
● When an appWindow is killed inactively by
gecko due to OOM or crash, it will enter
suspend state.
appWindow
SuspendingWindowManager
suspended
appWindow
suspended
appWindow
suspended
mozbrowsererror
mozbrowsererror
mozbrowsererror
appWindow
timestamp: 1
SuspendingWindowManager
appWindow
timestamp: 0
appWindow
timestamp: 2
resumedlaunch
appWindow
timestamp: 1
SuspendingWindowManager
appWindow
timestamp: 0
appWindow
timestamp: 9
appWindow
timestamp: 10
suspended
kill the oldest
*WindowManager
*Window *Window (active)
Modules affecting
transition
*Window
Transition
FSM
*Window
request to open
close the active instance
Basically only the same
type window will be taken
into account.
WindowManager
*Window *Window
Modules affecting
transition
*DialogManager
Transition
FSM
*Window
admit the request or ignore by
*Window.open();
MultiTasking - Nested Windows
Dialer App Gallery AppHomescreen App Contact App
Contact Activity
Gallery Activity
Camera Activity
Camera App
MultiTasking - Nested Windows
AppWindow
AppWindowAppWindow
AppWindow
ActivityWindow
Activity
Window
ActivityWindow
AppWindow
FrontWindow is rendered inside BottomWindow’s container.
AppWindow#1
Activity
Window#A
Nested Window
Activity
Window#B
● AppWindow#1 manages ActivityWindow#A
● ActivityWindow#A manages ActivityWindow#B
● Only parentWindow/childWindow refers each
other; the grandparentWindow(AppWindow#1)
does not need to know the state of the
grandchildWindow(ActivityWindow#B)
● However, kill a parentWindow will kill the
childWindow which causes a chaining kill.
We are having a principal pattern now.
AppWindowManagerAppWindow AppWindow
Application Core
AppWindow AppWindow
AppWindow
One Manager + Instances Pattern fits usual webapp
management requirements.
Hierarchy
In an operation system, there would be some
system level user interface which are not usual
applications but has certain interaction with
applications.
Lockscreen, Attention, SystemDialog,
Rocketbar...
We are having a principal pattern now.
Scale this design.
One App =>
Multiple App =>
Multiple Tasking =>
Multiple Hierachy
AppWindowManagerAppWindow AppWindow
Application Core
LockscreenWindow
Manager
Lockscreen
Window
Ability to extend the manager
AppWindowManagerAppWindow AppWindow
Application Core
LockscreenWindow
Manager
Lockscreen
Window
Keep the interactions between new
windows
AttentionWindow
Manager
Attention
Window
Attention
Window
Manager of Managers
Hierarchy management
Hierarchy Management
● Visibility Management
● Orientation Management
● Layout Management
Lowlevel Windows
Highlevel Windows
Manager
1. Request
2. Detect
3.Perform/
Ignore
Operations across windows is controlled by specfic manager.
Hierarchy events
● resize
● orientation
● visibility
● home
Hierarchy Management
● Visibility Management
● Orientation Management
● Layout Management
LayoutManager
*Window
KeyboardManager SoftwareHomeButton
*WindowManager
*Window *Window *Window
*WindowManager*WindowManager
dispatch resize command to
highest priority manager
Modules affecting
layout
execute resize to active window
resize
VisibilityManager
*Window
*Window *Window
*WindowManager*WindowManager*WindowManager
dispatch background command to
lower priority manager
Modules affecting
visibility
execute setVisible to active window
*DialogManager
*Window
VisibilityManager
*Window *Window
Modules affecting
visibility
*DialogManager
Transition
FSM
request to foreground
*Window
Check no higher priority module is active
VisibilityManager
*Window *Window
Modules affecting
visibility
*DialogManager
Transition
FSM
*Window
admit the request or ignore
by *Window.setVisible(true)
OrientationManager
*Window *Window
Modules affecting
orientation
*DialogManager
Transition
FSM
*Window
request lock orientation
Check no higher priority module is active
OrientationManager
*Window *Window
Modules affecting
orientation
*DialogManager
Transition
FSM
*Window
admit the request or ignore
This is not real now.
screen.requestLockOri
entation() is open to
web content.
System app should
have the ability to
manage orientation
request from
mozbrowser iframe.
Look at the Transition FSM closely
● statechange will trigger the inner handler
o Enter closed state: send to background
o Enter opened state: request to foreground
Develop a window manager
● What windows to manage/create?
● Reuse/Inherit AppWindow
● Make HierachyManagement Modules know
your existence
Best Practice: Rocketbar
● Search app is different from a normal
appWindow.
● Implement SearchWindow
● Implement
SearchWindowManager(rocketbar.js)
● Modify HierachyManagement Modules
PATTERNS USED
Patterns
● Manager Pattern
● *Observer Pattern
● Finite State Machine Pattern
Manager(Mediator) Pattern
● A manager is usually a singleton.
● What to manage? Interactions between
instances.
● A manager is expected to maintain a list
multiple instances coming from the same
class.
InstanceA
Manager
InstanceB
InstanceC
Instances should issue a request which needs cross instance knowledge to manager.
request an operation across instances
InstanceA
Manager
InstanceB
InstanceC
InstanceA has no knowledge about instanceB.
check states
InstanceA
Manager
InstanceB
InstanceC
permit the request after checking
other instances
Patterns
● Manager Pattern
● *Observer Pattern
● Finite State Machine
Event Publisher/Broadcaster Inner Subscriber
Inner Subscriber
Inner Subscriber
Outer Subscriber
Outer Subscriber
Outer Subscriber
Inside a module
The world
Event Publisher/Broadcaster Inner Subscriber
Inner Subscriber
Inner Subscriber
Outer Subscriber
Outer Subscriber
Outer Subscriber
Inside a module
The world
Patterns
● Manager Pattern
● *Observer Pattern
● Finite State Machine + Proxy
Finite State MachineEvents
FSM.processEvent(‘a’);
FSM.processEvent(‘a’);
FSM.processEvent(‘b’);
FSM.processEvent(‘c’);
statechange

More Related Content

Similar to Firefox OS Window management 201

Inside Android's UI at AnDevCon V
Inside Android's UI at AnDevCon VInside Android's UI at AnDevCon V
Inside Android's UI at AnDevCon V
Opersys inc.
 
Windows Store Apps: Tips & Tricks
Windows Store Apps: Tips & TricksWindows Store Apps: Tips & Tricks
Windows Store Apps: Tips & Tricks
Robert MacLean
 

Similar to Firefox OS Window management 201 (20)

Toronto User groups workshop - 2013-03-10 - HTML5 & Windows 8, friends with b...
Toronto User groups workshop - 2013-03-10 - HTML5 & Windows 8, friends with b...Toronto User groups workshop - 2013-03-10 - HTML5 & Windows 8, friends with b...
Toronto User groups workshop - 2013-03-10 - HTML5 & Windows 8, friends with b...
 
Android: the Single Activity, Multiple Fragments pattern | One Activity to ru...
Android: the Single Activity, Multiple Fragments pattern | One Activity to ru...Android: the Single Activity, Multiple Fragments pattern | One Activity to ru...
Android: the Single Activity, Multiple Fragments pattern | One Activity to ru...
 
Google I/O 2019 - what's new in Android Q and Jetpack
Google I/O 2019 - what's new in Android Q and JetpackGoogle I/O 2019 - what's new in Android Q and Jetpack
Google I/O 2019 - what's new in Android Q and Jetpack
 
Caliburn.micro
Caliburn.microCaliburn.micro
Caliburn.micro
 
Building Beautiful and Interactive Metro apps with JavaScript, HTML5 & CSS3
Building Beautiful and Interactive Metro apps with JavaScript, HTML5 & CSS3Building Beautiful and Interactive Metro apps with JavaScript, HTML5 & CSS3
Building Beautiful and Interactive Metro apps with JavaScript, HTML5 & CSS3
 
Dive into Angular, part 5: Experience
Dive into Angular, part 5: ExperienceDive into Angular, part 5: Experience
Dive into Angular, part 5: Experience
 
MVP vs MVVM : a fast introduction
MVP vs MVVM : a fast introductionMVP vs MVVM : a fast introduction
MVP vs MVVM : a fast introduction
 
VIPER ( ? OR : AND) MVVM
VIPER ( ? OR : AND) MVVMVIPER ( ? OR : AND) MVVM
VIPER ( ? OR : AND) MVVM
 
A journey through android development
A journey through android developmentA journey through android development
A journey through android development
 
An end-to-end experience of Windows Phone 7 development (Part 1)
An end-to-end experience of Windows Phone 7 development (Part 1)An end-to-end experience of Windows Phone 7 development (Part 1)
An end-to-end experience of Windows Phone 7 development (Part 1)
 
Introduction to Magento 2 module development - PHP Antwerp Meetup 2017
Introduction to Magento 2 module development - PHP Antwerp Meetup 2017Introduction to Magento 2 module development - PHP Antwerp Meetup 2017
Introduction to Magento 2 module development - PHP Antwerp Meetup 2017
 
The Ring programming language version 1.5.4 book - Part 71 of 185
The Ring programming language version 1.5.4 book - Part 71 of 185The Ring programming language version 1.5.4 book - Part 71 of 185
The Ring programming language version 1.5.4 book - Part 71 of 185
 
Building for multiple devices using a single language and framework
Building for multiple devices using a single language and frameworkBuilding for multiple devices using a single language and framework
Building for multiple devices using a single language and framework
 
Mojito: Building for multiple devices using a single language and framework
Mojito: Building for multiple devices using a single language and frameworkMojito: Building for multiple devices using a single language and framework
Mojito: Building for multiple devices using a single language and framework
 
The web - What it has, what it lacks and where it must go - keynote at Riga D...
The web - What it has, what it lacks and where it must go - keynote at Riga D...The web - What it has, what it lacks and where it must go - keynote at Riga D...
The web - What it has, what it lacks and where it must go - keynote at Riga D...
 
Inside Android's UI at AnDevCon V
Inside Android's UI at AnDevCon VInside Android's UI at AnDevCon V
Inside Android's UI at AnDevCon V
 
Android design patterns
Android design patternsAndroid design patterns
Android design patterns
 
Win8 development lessons learned jayway
Win8 development lessons learned jaywayWin8 development lessons learned jayway
Win8 development lessons learned jayway
 
Voo doodriver training
Voo doodriver trainingVoo doodriver training
Voo doodriver training
 
Windows Store Apps: Tips & Tricks
Windows Store Apps: Tips & TricksWindows Store Apps: Tips & Tricks
Windows Store Apps: Tips & Tricks
 

Recently uploaded

VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
dharasingh5698
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Kandungan 087776558899
 
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoorTop Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
dharasingh5698
 
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
amitlee9823
 
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Recently uploaded (20)

Unit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfUnit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdf
 
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
 
Unit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdfUnit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdf
 
Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
 
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoorTop Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineering
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptx
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
 
Intro To Electric Vehicles PDF Notes.pdf
Intro To Electric Vehicles PDF Notes.pdfIntro To Electric Vehicles PDF Notes.pdf
Intro To Electric Vehicles PDF Notes.pdf
 
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 

Firefox OS Window management 201