User Proximity Sensor

We want to make it even easier to use device APIs.  Device Proximity has a sister spec called User Proximity that allows you to be notified when the user is “near” or “far”.  So, instead of looking at sensor values and determining where the user is, you can simple register for a callback:

window.addEventListener("userproximity", callback, true);
function callback(a) {
// d=
 if (a.near) d.innerHTML = "User is near" else d.innerHTML = "User is far" }

This work is being tracked in Bug 751663 and should be landed soon.

Print X pixmap from GDB

#
# Print an X pixmap
#
define ppixmap
    if $argc != 1
        help ppixmap
        else
           set $pixmap = $arg0
           set $cmd = PR_smprintf(“view-pixmap %lu &”, $pixmap)
           set $_ = system($cmd, “w”)
           printf “Launched %s\n”, $cmd
        end
end

document ppixmap
    Launches a process to display an X pixmap
    Syntax: ppixmap <pixmapXID>
end

Android Test codes

Android Test codes


*#*#4636#*#* Display information about Phone, Battery and Usage statistics
*#*#7780#*#* Restting your phone to factory state-Only deletes application data and applications
*2767*3855# It’s a complete wiping of your mobile also it reinstalls the phones firmware
*#*#34971539#*#* Shows completes information about the camera
*#*#7594#*#* Changing the power button behavior-Enables direct poweroff once the code enabled
*#*#273283*255*663282*#*#* For a quick backup to all your media files
*#*#197328640#*#* Enabling test mode for service activity
*#*#232339#*#* OR *#*#526#*#* OR *#*#528#*#* Wireless Lan Tests
*#*#232338#*#* Displays Wi-Fi Mac-address
*#*#1472365#*#* For a quick GPS test
*#*#1575#*#* A Different type GPS test
*#*#0283#*#* Packet Loopback test
*#*#0*#*#* LCD display test
*#*#0673#*#* OR *#*#0289#*#* Audio test
*#*#0842#*#* Vibration and Backlight test
*#*#2663#*#* Displays touch-screen version
*#*#2664#*#* Touch-Screen test
*#*#0588#*#* Proximity sensor test
*#*#3264#*#* Ram version
*#*#232331#*#* Bluetooth test
*#*#7262626#*#* Field test
*#*#232337#*# Displays bluetooth device address
*#*#8255#*#* For Google Talk service monitoring
*#*#4986*2650468#*#* PDA, Phone, Hardware, RF Call Date firmware info
*#*#1234#*#* PDA and Phone firmware info
*#*#1111#*#* FTA Software version
*#*#2222#*#* FTA Hardware verion
*#*#44336#*#* Displays Build time and change list number
*#06# Displsys IMEI number
*#*#8351#*#* Enables voice dialing logging mode
*#*#8350#*#* Disables voice dialing logging mode

Device Light Sensor

Tags

,

Similar to proximity, Many devices also have light sensors embedded in them. To expose this to web content we should just use DOM Events similar to that of Device Motion and Device Orientation. A developer simply has to register an event listener:


window.addEventListener("devicelight", callback, true);

The callback’s parameters include:

value – the current ambient light level in SI lux units


function callback(a) {
var d = document.getElementById("d");
d.innerHTML = "<p> Current Value " + a.value
}

Like Device Proximity, the sensor will be turned on when the first listener is added. And, of course, the sensor will be turned off when the last event listener is removed.

This work is being tracked in bugzilla bug 738465. Sample webpage: http://dl.dropbox.com/u/8727858/mozilla/light/light.html

I hope to get this in for Firefox 14 or 15, and of course, B2G.

Device Proximity

Tags

, ,

Many devices have proximity sensors embedded in them.  To expose this to web content we should just use DOM Events similar to that of Device Motion and Device Orientation.  A developer simply has to register an event listener:


window.addEventListener("deviceproximity", callback, true);

The callback’s parameters include:

value – the current distance to the proximity sensor in cm.
min – the minimum value that the sensor and report.  Usually zero.
max – the maximum value that the sensor can report.


function callback(a) {
var d = document.getElementById("d");
d.innerHTML = "<p> Current Value " + a.value +  "<p> Max = " + a.max +  "<p> Min = " + a.min
}

Like Device Motion and Device Orientation, the sensor will be turned on when the first listener is added.  And, of course, the sensor will be turned off when the last event listener is removed.

This work is being tracked in bugzilla bug 738131.  Sample webpage:  http://dl.dropbox.com/u/8727858/mozilla/proximity/pro.html

I hope to get this in for Firefox 14 or 15, and of course, B2G.

Geolocation V2 removed from Gecko

I implemented the W3C Geolocation API V2 specification ahead of the other browsers. In this API, web sites can not only request a latitude and longitude but also request a physical mailing address. It does this by ‘geocoding’ the latitude and longitude pair using a third party service.  These services typically cost a lot.  On the desktop, I disabled this feature after a few months of it live.  After the removal, I did not receive any emails that things ‘broke’.  Hence, I believe there is little demand for V2.

I am going to remove support for V2 in Mozilla.  In the future, if there is a demand, I think the right approach is to expose geocoding to the web as a separate API.  Stay Tuned.

Running Eve over SSH

If you wanted to run Eve Online from somewhere where the ports are blocked and you have access to a machine that is running sshd:

ssh -L 26000:87.237.38.200:26000 -p2442 <your home ip>

/Applications/EVE\ Online.app/Contents/MacOS/./cider “C:\Program Files\CCP\EVE\eve.exe” /end /server:127.0.0.1

Mozilla Fennec Future – A post from the past

Tags

, , , ,

I wrote this back in October.  Never posted it.  Here it is for posterity and maybe some quick reflections.

Start-up performance and memory usage have been the two of the biggest concerns our users have had with Firefox for Android.  On the fastest Android devices, the browser starts up in about 2 seconds.  We, and our users, believe that this is completely unacceptable.  We have been exploring ways to improve both startup speed and memory usage.  One of the outcomes has been to build a prototype that uses Android’s native UI instead of XUL.  Although not a silver bullet, this prototype shows big wins in both areas.

Historically we’ve built our Android user interface with XUL.  XUL is a very flexible UI toolkit.  This flexibility comes at a cost. It requires that we have to load all of Gecko, our rendering engine, before being able to start using XUL.  So, before we can show any browser UI, we have to load all of Gecko.  A lot of progress has been made to improve Gecko startup, but we aren’t able to provide the same startup experience that native Java widgets can provide.  Just to be clear, this isn’t actually because XUL is slow, it is just that, on Android, bring up native widgets is very fast and loading libraries is very slow.

Our prototype shows that we have a 6MB RSS memory win when comparing our current build to a Fennec nightly build.  This doesn’t include the RSS usage caused by a second ‘child’ gecko process.  We can have a fully functional Awesome Bar up and ready for you in under 300ms.  Keep in mind that this is a prototype and the actual numbers of a more full featured browser will vary.

A native UI will have some challenges of its own to overcome. We’re coordinating with the Jetpack project to build strong support for extensions. We’re talking with our localization teams about how to ensure we support users around the world.

Our hope is to build future versions of the Firefox for Android user interface using native Java.  Our engineering teams are already taking this project on with the aim of building this technology into the Firefox for Android experience. It’s too early to estimate when we’ll be ready to replace the XUL UI, but the team is working quickly and with focus.

We have a lot of work to do, and you can help.  If you would like to get involved, especially if you have experience building native Android applications, now is the time. Take a look at https://wiki.mozilla.org/Fennec/NativeUI for more information, or grab the source from http://hg.mozilla.org/projects/birch/.  Also see the mozilla dev-planning mailing list for a discussion.

Fennec and Native Android UIs

Tags

, , , ,

Bringing up a User Interface (UI) as fast as possible is a very important goal and benchmark of any application. People don’t want to wait for their applications to load. Most applications on Android show a UI in under 300 milliseconds (ms). Fennec doesn’t hit that goal and is a major concern for us.

The problem is that Gecko (our rendering engine) isn’t loaded when Fennec starts. We need to load Gecko into memory, start Gecko, then wait while it renders our UI from XUL. This is a lot of waiting around for us to show a relatively simple UI.

Droid Pro

Not a super fast phone.

At the Mozilla AllHands, Andreas Gal, Chris Jones, and Patrick Walton built a simple browser using a Android native front end instead of XUL. They showed a simple native UI around Gecko could be started in under 300 milliseconds. The idea is that the user immediately sees a familiar browser UI and while they are typing a uri or interacting with the UI, we load Gecko in the background. Their demo, although not complete, was dramatic and did not show any startup problems.

Using a native UI does imply certain things. Clearly add-ons, specifically XUL overlays, will not work as-is. Mozilla’s Embedding API has been kinda-sorta deprecated and we may need to use those APIs to make a better app. There may be other issues that come up.

To figure out these issues, we are starting a team to build out a more full featured demo. The work can be followed on github (git@github.com:snorp/mozilla-central.git branch faster). If you are interested, please drop me an email, or send me a pull request.

Lastly, and most importantly, we will continue the existing XUL-based Fennec project and future Firefox on Mobile will still be based on the XUL front-end. The team will continue focusing on startup performance, memory usage, bugs fixes, and features. The Native Android UI project is an investigation at this point.

NPAPI on Android status update 2.

Tags

, , , ,

Before I start:  I am going to say “Flash” in this blog post a few time.  I am also going to say “Fennec”.  I am not going to say “I like Flash” or “I do not like Flash”.  I am also not going to say “We are shipping Flash support”.  This blog post is about the progress we have been making on getting NPAPI and Flash working in Fennec.  Decisions to ship such support is another topic.  Please think of this as a feasibility study… an informal one.

I went for a short vacation and recently picked up the Android NPAPI implementation for Fennec.  When I left, we had some basic bitmap drawing going.  As you may recall, the Webkit Android NPAPI has a few different drawing models.  The first one (and easiest to understand and get bootstrapped) is called Bitmap Model.  It basically is a piece of memory that you can hand to the plugin and the plugin will call back on a set of functions that you have registered with it.  These sets of functions (interfaces) are a simple wrapper around Skia.  So, we got the sample plugin loaded and saw a blue ball bouncing around.  Yay.

Next step was to get the next drawing model working.  This one is called the Java Surface Model.  Two things about this drawing model.  First, it is super important as it is the model that we believe that Adobe Flash uses exclusively.  If we get this model right, the other’s are far less important.  The other thing is that this model is very scary as it uses Java.  Recall that Fennec doesn’t have access to the Java runtime in the child process.  (because for responsiveness Fennec uses multiple processes — one for the UI, one for the web content.  The web content process doesn’t have access to Java).  So, while I was on the beach and making tough decisions like which beach to go to tomorrow, Brad Lassey started reflecting the JNI interface over our IPC layer.  Yes, he is fearless.  His work allows you to make JNI calls from the child.  So, if you want to create a new Java string, you can use his interface from the child process and it will return an opaque pointer to a new Java string that was created in the parent.  This is not meant to be a general JNI remoting service (but could develop into one).  The intent is to only get as much JNI remoting needed in order to load Flash.

So, that brings us to my last hack session. The way this drawing model works is that the plugin asks you what you support.  We say, we support these drawing models, Bitmap and Java Surface.  The plugin we are targeting rather do things with a Java Surface, so it asks that we use that drawing model.  After the plugin finishes draw model negotiation and initialization, it is ready to go.  We just have to get its “surface” and render it to the screen.  To do this, we make a standard NPAPI GetValue call to the plugin and use the define kJavaSurface_ANPGetValue.  Here is the comment that is in the android_npapi.h header file:

/** Requests that the plugin return a java surface to be displayed. This will
only be used if the plugin has choosen the kSurface_ANPDrawingModel.

NPP_GetValue(inst, kJavaSurface_ANPGetValue, jobject surface)
*/
#define kJavaSurface_ANPGetValue            ((NPPVariable)2000)

A couple of sad points:

  • This interface was never standardized and this GetValue may eventually collide with some another GetValue key.  Not really sure what should be done here other than document it.
  • The “surface” return isn’t a Surface at all.  Instead, it is a View.  The comment and the #define name are completely bogus.  Looking at the sample plugin, it is clear the result of the GetValue call is a subclass of View, not of Surface.

Ignoring that, if the call is successful, the plugin should have created a View and will draw into it as soon as that View is attach to some View Manager.  (Note:  you can’t access the raw bitmap from this drawing model.  If you could, it would integrate much nicer into Fennec.).  To get this View into our ViewManager, we have to tell the parent process about it.  This is basically where I ended last night.  For a simple check point, I forwarded the View pointer to the parent, and absolutely placed it in our ViewManager. Guess what, it worked.  We could see a little 3D object spinning around in the browser.  Well, above the browser.  Partial Yay.

Next steps are to clean the code up a bit, have the plugin object be position and scaled appropriately, and fix more bugs along the way.

Follow

Get every new post delivered to your Inbox.