MDN Hackday London - Boot to Gecko: The Future of Mobile

56
BOOT TO GECKO The future of mobile? Rob Hawkes Hi, I’m Rob Hawkes and I’m here today to talk about Mozilla’s Boot to Gecko project.

description

In this talk Rob will outline Mozilla’s Boot to Gecko project that aims to revolutionise the way we develop for mobile devices. I’ll highlight the key technologies involved in its creation and explain why a mobile experience created with HTML and JavaScript is a good idea.

Transcript of MDN Hackday London - Boot to Gecko: The Future of Mobile

Page 1: MDN Hackday London - Boot to Gecko: The Future of Mobile

BOOT TO GECKO

The future of mobile?

Rob Hawkes

Hi, I’m Rob Hawkes and I’m here today to talk about Mozilla’s Boot to Gecko project.

Page 2: MDN Hackday London - Boot to Gecko: The Future of Mobile

Boot to Gecko (B2G)

The Web as a platform

Boot to Gecko, referred to as B2G, is a full operating system and platform for mobile devices.

Page 3: MDN Hackday London - Boot to Gecko: The Future of Mobile

B2G Gaia

B2G is actually two separate things; B2G and Gaia

The B2G side is the hardware-related stuff and JavaScript APIs that we need to make the phone work.

The B2G side is pretty much everything that you don’t see.

Page 4: MDN Hackday London - Boot to Gecko: The Future of Mobile

Gaia is the front-end operating system and application stack that hooks into the APIs that B2G provides.

Gaia is basically everything that you can see and interact with.

Page 5: MDN Hackday London - Boot to Gecko: The Future of Mobile

At the basic level, B2G is powered by HTML5 and JavaScript – the same technologies that you already use to create websites.

This makes it incredibly fast. I’m talking really fast, it boots and shuts down in a fraction of the time that an iPhone does.

Page 6: MDN Hackday London - Boot to Gecko: The Future of Mobile

Why B2G?

What is all the fuss about?

But why is B2G important?

Well to put it simply, HTML5 & JavaScript are the underlying technologies behind everything related to the future of the Web.

Pretty much every new technology that is coming out within the browser-space is connected to HTML5 and JavaScript in some way.

And what’s great is that every major browser has invested in them, so they won’t be going anywhere any time soon.

But there’s more to it than that.

Page 7: MDN Hackday London - Boot to Gecko: The Future of Mobile

Open technologies

Anyone can view the source code

It is created with open technologies.

Anyone can get involved in their creation; through browser developers like Mozilla, or through standards organisations like the W3C.

Also, these technologies are open in that anyone can view the resulting code that is used within Web pages, which is a fantastic way of learning.

Page 8: MDN Hackday London - Boot to Gecko: The Future of Mobile

Free technologies

Free to use. Free to develop with

It is created with free technologies.

Anyone can use these technologies without having to pay anything, both for using the technology and developing with it.

This is unlike closed environments like iOS where you have to pay to use official code editors and production environments.

Page 9: MDN Hackday London - Boot to Gecko: The Future of Mobile

Firefox Persona

B2G

Web Apps

B2G is also part of the Kilimanjaro event.

Kilimanjaro is a milestone across several of the Mozilla products; Firefox, B2G, Web Apps, and Persona.

The Kilimanjaro Event is not a single release, it is an incremental effort that results in an coherent experience across those products.

When we reach the Kilimanjaro milestone we will have an elegant and simple experience for HTML5 Web apps in Firefox on multiple devices that puts the user in control of their apps and identity.

‘Kilimanjaro’ is planned to be reached by September 2012.

https://wiki.mozilla.org/Kilimanjaro

Page 10: MDN Hackday London - Boot to Gecko: The Future of Mobile

Demo

I think the best way to explain B2G and to show it’s current state is to give you a quick demo.

Page 11: MDN Hackday London - Boot to Gecko: The Future of Mobile

Technology behind B2G

The same stuff you build websites with

B2G is created from a whole variety of technologies, from pre-existing ones to brand new ones that have been created specifically.

Page 12: MDN Hackday London - Boot to Gecko: The Future of Mobile

Firefox Gecko

The Gecko engine lays at the core of B2G, the same engine that powers Firefox.

Needless to say, B2G isn’t just Firefox running on a phone. It’s much more than that.

Page 13: MDN Hackday London - Boot to Gecko: The Future of Mobile

Multitouch

WebBluetooth

WebGL

WebTelephony

WebSMS

WebNFC

Geolocation

CameraWebUSB

Battery API

WebContacts

Full Screen API

Settings API

WebVibration

At Mozilla we’re working on the WebAPI effort which is our attempt at creating the APIs needed to run a B2G device.

In other camps it might be referred to as DAP, which is the Device APIs Working Group who are producing a W3C specification for accessing various parts of a device through JavaScript.

The illustration above shows just a few of the APIs for B2G that we’re working on right now.

Page 14: MDN Hackday London - Boot to Gecko: The Future of Mobile

My favourites

Device APIs I cannot wait fo

r

There are so many WebAPIs and technologies in the pipeline that relate to B2G in some way.

The following are just a few of my favourites.

You can find the rest of the WebAPIs here: https://wiki.mozilla.org/WebAPI

Page 15: MDN Hackday London - Boot to Gecko: The Future of Mobile

Touch Events

Multitouch and gestures

Touch Events

https://developer.mozilla.org/en/DOM/Touch_events

Page 16: MDN Hackday London - Boot to Gecko: The Future of Mobile

Camera API

Accessing the camera

The Camera API lets you access the camera on a device.

Being able to do this with JavaScript will make a whole world of difference in so many areas.

For example, instead of requiring a user to upload a profile image you could take one using the webcam and use that instead. Simple but effective.

https://wiki.mozilla.org/Platform/Features/Camera_API

Page 17: MDN Hackday London - Boot to Gecko: The Future of Mobile

WebSMS API

Sending texts with JavaScript. ‘Nuff s

aid

The WebSMS API isn’t the most glamorous, but the idea of sending text messages with JavaScript is quite appealing.

https://bugzilla.mozilla.org/show_bug.cgi?id=674725

Page 18: MDN Hackday London - Boot to Gecko: The Future of Mobile

WebTelephony API

Make and receive calls

The WebTelephony API allows you to make and receive phone calls using JavaScript.

I can just imagine something like this being used to hook into a Web-based version of Siri that answers your calls for you if you’re busy.

https://bugzilla.mozilla.org/show_bug.cgi?id=674726

Page 19: MDN Hackday London - Boot to Gecko: The Future of Mobile

WebVibration API

Vibrating you with open technologies

WebVibration API, previously known as the WebVibrator API

https://bugzilla.mozilla.org/show_bug.cgi?id=679966

Page 20: MDN Hackday London - Boot to Gecko: The Future of Mobile

WebNFC API

RFID-like wireless communication

The WebNFC API is pretty cool.

It gives you the ability to transmit and receive data within distances no larger than a few centimetres.

The idea is that it can be used in phones for things like payment (like the new Barclaycard), travel (think Oyster Card), and file transfer.

https://bugzilla.mozilla.org/show_bug.cgi?id=674741

Page 21: MDN Hackday London - Boot to Gecko: The Future of Mobile

WebBluetooth API

Access to bluetooth hardware

WebBluetooth API

https://bugzilla.mozilla.org/show_bug.cgi?id=674737

Page 22: MDN Hackday London - Boot to Gecko: The Future of Mobile

Battery API

Monitoring power usage

Battery API

https://bugzilla.mozilla.org/show_bug.cgi?id=678694

Page 23: MDN Hackday London - Boot to Gecko: The Future of Mobile

Full Screen API

Simple, yet powerful

The Full Screen API allows you to expand any HTML element to fill the users screen, even if the browser isn’t running full screen itself.

https://bugzilla.mozilla.org/show_bug.cgi?id=545812https://wiki.mozilla.org/Platform/Features/Full_Screen_APIs

Page 24: MDN Hackday London - Boot to Gecko: The Future of Mobile

Screen Orientation

Changing and locking of orientation

The Screen Orientation APIs allow you to do things like changing and locking, you guessed it, the orientation of the screen.

Before now, it’s been incredibly difficult to lock orientation on a website or game using nothing but JavaScript.

https://bugzilla.mozilla.org/show_bug.cgi?id=740188http://dvcs.w3.org/hg/screen-orientation/raw-file/default/Overview.html

Page 25: MDN Hackday London - Boot to Gecko: The Future of Mobile

WebGL

Hardware-accelerated graphics

WebGL brings the ability to provide advanced hardware-accelerated 2D and 3D graphics directly within the browser.

https://developer.mozilla.org/en/WebGL

Page 26: MDN Hackday London - Boot to Gecko: The Future of Mobile

Open Web Apps

Building upon the Web as a platform

Open Web Apps is an initiative that is core to B2G and one that is important to the Web as a whole.

It’s a way of creating and distributing apps that puts the developers and users of apps back in charge.

It’s a way that embraces open technology and is for the good of the Web.

Page 27: MDN Hackday London - Boot to Gecko: The Future of Mobile

Reach

Apps can be used cross-platform

It allows you to create rich HTML5 app experiences that run across multiple devices and form factors (desktop, mobile, tablet, etc.)

Page 28: MDN Hackday London - Boot to Gecko: The Future of Mobile

Open technology

What you already use to make websites

It allows you to use Web standards and open technologies such as HTML5, CSS and JavaScript.

Anything you currently use to build a website with can be used to build an app.

Page 29: MDN Hackday London - Boot to Gecko: The Future of Mobile

Freedom of choice

Putting devs and consumers in control

It puts you in control of every aspect of the app experience; from easy development, to distribution, to direct communication with your customers.

Page 30: MDN Hackday London - Boot to Gecko: The Future of Mobile

The Mozilla Marketplace is our own platform for selling and distributing Web apps.

It’s in development right now but we plan to open the doors later this year.

However, there’s nothing to stop you creating your own marketplace though. All the APIs to do that are documented and built into Firefox today. In fact, we encourage it!

https://marketplace.mozilla.orghttps://developer.mozilla.org/en/Apps

Page 31: MDN Hackday London - Boot to Gecko: The Future of Mobile

Getting started

How to create an app

Creating a Web app isn’t crazy hard, it’s just a case of understanding the new features in browsers.

https://developer.mozilla.org/en/Apps

Page 32: MDN Hackday London - Boot to Gecko: The Future of Mobile

Apps are websites

They use the same technology

Apps are websites and are built using the same technology and processes.

If you already know how to make a website then creating your first Web app is a breeze.

Page 33: MDN Hackday London - Boot to Gecko: The Future of Mobile

Application manifest

Turning a website into an app

The only thing that you need to do to turn a website into app is create an application manifest.

Page 34: MDN Hackday London - Boot to Gecko: The Future of Mobile

{

"version": "1.0",

"name": "MozillaBall",

"description": "Exciting Open Web development action!",

"icons": {

"16": "/img/icon-16.png",

"48": "/img/icon-48.png",

"128": "/img/icon-128.png"

},

"developer": {

"name": "Mozilla Labs",

"url": "http://mozillalabs.com"

},

"installs_allowed_from": [

"https://appstore.mozillalabs.com"

],

"default_locale": "en"

}

This is a JSON file that effectively describes your application; it’s name, icons, and other related data.

Page 35: MDN Hackday London - Boot to Gecko: The Future of Mobile

Manifest requirements

Important to remember

There are a couple of important things to remember when creating an application manifest.

Page 36: MDN Hackday London - Boot to Gecko: The Future of Mobile

Same domain

An element of security

The first is that it needs to be hosted from the same domain as your Web app.

This is pretty straightforward and it adds an element of security in that it is unlikely that a rouge manifest file will be able to be put on the same domain without your knowledge.

Page 37: MDN Hackday London - Boot to Gecko: The Future of Mobile

Content-type header

application/x-web-app-manifest+json

The second is that it needs to be served with a specific content type (application/x-web-app-manifest+json).

This is probably the most tricky process in turning a website into an app as it involves changing settings on your server or a bit of hackery in your manifest file.

If you don’t want to fiddle with your server then you can always set the content-type header using something like PHP or Node.js.

Page 38: MDN Hackday London - Boot to Gecko: The Future of Mobile

Manifest validator

Making sure everything is ok

If you want to make sure your manifest is valid you can have it checked at http://appmanifest.org

Page 39: MDN Hackday London - Boot to Gecko: The Future of Mobile

Installing apps

Through the browser or Marketplace

You can install apps in B2G through the browser or the Mozilla Marketplace.

You can also install apps on the desktop and Android using Firefox.

Page 40: MDN Hackday London - Boot to Gecko: The Future of Mobile

Installing an app

navigator.mozApps.install(manifestUrl)

Behind the scenes, installing an app is achieved through the new mozApps JavaScript API.

By passing the ‘install’ method a string URL to the app’s manifest file you will trigger the installation process.

An example of when you would call this method is after a user clicks on an “Install this app” button on your own website.

It would be called automatically if your app was installed from the Mozilla Marketplace, or any other external website.

Page 41: MDN Hackday London - Boot to Gecko: The Future of Mobile

The install method triggers an installation dialogue within the browser that allows the user to decide what to do with the app.

On Windows, a desktop shortcut is created for the app you installed and it will also be in the start menu.

On Mac, the app is added to your /Applications directory.

On B2G, the app is added to your homescreen.

Page 42: MDN Hackday London - Boot to Gecko: The Future of Mobile

Using B2G today

There are a few options

There are a whole bunch of ways to start using and testing B2G today.

Page 43: MDN Hackday London - Boot to Gecko: The Future of Mobile

If you have some knowledge of git, you can clone the Gaia repository and launch Gaia using a recent Firefox Nightly build.

Pros: - No build system  and very little setup required- Can use the Firefox dev tools

Cons:- The viewport is based on the size of the browser window- Many device-like things won't work- Apps are launched in separate, pinned tabs- Firefox Nightly might be unstable

http://nightly.mozilla.orghttps://github.com/andreasgal/gaia/

Page 44: MDN Hackday London - Boot to Gecko: The Future of Mobile

There is also gaia-devserver, a node-based tool for developing Gaia in Firefox Nightly.

https://github.com/jrburke/gaia-devserver

Page 45: MDN Hackday London - Boot to Gecko: The Future of Mobile

Gaia in Nightly

You’ll have to resize the browser to get it looking right but it’s a great way to quickly play with Gaia and start developing for it.

Page 46: MDN Hackday London - Boot to Gecko: The Future of Mobile

B2G Simulator

It is also possible to build a Boot to Gecko 'simulator' and run Gaia using this application. This software is based on Firefox but behaves similar to the on-device experience of Boot to Gecko.

If you are familiar with building the Firefox code-base or C++ projects, you can build this application yourself.

Pros: - Mobile viewport, similar experience to a mobile device in most respects- More device apis (not all)

Cons:- Need to install a C/C++ build system and build gecko- The Firefox dev tools are not available

https://wiki.mozilla.org/Gaia/Hacking#Building_B2G

Page 47: MDN Hackday London - Boot to Gecko: The Future of Mobile

B2G Device

The last option is to build B2G on your own device.

This is the most difficult option and is only recommended on a spare device by someone who knows what they’re doing.

We’re constantly improving the method of getting B2G onto your own device so we hope that it will be a lot more reliable and safer in the near future.

https://developer.mozilla.org/en/Mozilla/Boot_to_Gecko#Setting_up_.26_building_Boot_to_Gecko

Page 48: MDN Hackday London - Boot to Gecko: The Future of Mobile

Gaia hackery

Pushing apps to the hack device

The 10 devices that we’ve brought along for you today are already set up ready to have applications pushed to them and things tweaked.

To do that you’ll need to plug the device into your computer and directly push updates to it.

This approach is useful for development as it allows you to quickly test things without having to upload the app to the Web and installing or updating it from there.

https://wiki.mozilla.org/B2G/DeveloperPhone#Advanced_Gaia_Hacking

Page 49: MDN Hackday London - Boot to Gecko: The Future of Mobile

The first thing you need is the Android Debug Bridge.

This allows you to communicate between your computer and the B2G device via a USB cable.

http://developer.android.com/sdk/index.html

Page 50: MDN Hackday London - Boot to Gecko: The Future of Mobile

Dev installation

https://github.com/andreasgal/gaia/

The next step, if you haven’t got it already, is to download Gaia from GitHub.

The very latest version may be unstable so it’s recommended to use the build that we’ve brought along and can provide you on a memory stick.

https://github.com/andreasgal/gaia/

Page 51: MDN Hackday London - Boot to Gecko: The Future of Mobile

Dev installation

Add app to ‘../gaia/apps/myapp’

Once you have Gaia then add or create your application in the ‘../gaia/apps/myapp’ directory.

Make sure to include the application manifest file.

Page 52: MDN Hackday London - Boot to Gecko: The Future of Mobile

Dev installation

make install-gaia

The last step is to push your app and any Gaia updates to the device.

That’s it!

Page 53: MDN Hackday London - Boot to Gecko: The Future of Mobile

Contributing to B2G

You can help create the future

There are plenty of ways to get involved with B2G, from development all the way to general testing.

The best way to keep up to speed with things is to frequent the B2G mailing lists.

- https://lists.mozilla.org/listinfo/community-b2g- https://groups.google.com/forum/#!forum/mozilla.dev.b2g

If you want to help with development then the best place to do that is on the B2G and Gaia GitHub repositories.

- https://github.com/andreasgal/B2G/- https://github.com/andreasgal/gaia/

Page 54: MDN Hackday London - Boot to Gecko: The Future of Mobile

Talk to us

We live on Mozilla IRC

The general rule of thumb at Mozilla is to look for the relevant people on IRC if you want a quick response, we tend to live on there.

The server you want is irc.mozilla.org

The channels you want are #b2g and #gaia for B2G-related stuff, #openwebapps for Open Web Apps, and #webapi for anything about WebAPIs.

Page 55: MDN Hackday London - Boot to Gecko: The Future of Mobile

Threshold of something cool

This is just the beginning

I think it’s amazing that we can now build an entire operating system for a phone using Web technologies. It just blows my mind.

We really are on the threshold of something awesome here.

I definitely advise you to start checking out B2G and the related projects, developing for them, and helping with their development.

I’d love to see a day where all sorts of devices are powered by the Web, like TVs and set-top boxes.

Perhaps we’ll even get those Internet-enabled fridges that we desire so much!

Page 56: MDN Hackday London - Boot to Gecko: The Future of Mobile

THANK YOU

Question? Grab me later

Rob Hawkes

@robhawkes

Thank you.

If you have any questions feel free to grab me here, on Twitter (@robhawkes)