Tag Archives: sync

Things I’ve Learned This Week (April 13 – April 17, 2015)

When you send a sync message from a frame script to the parent, the return value is always an array

Example:

// Some contrived code in the browser
let browser = gBrowser.selectedBrowser;
browser.messageManager.addMessageListener("GIMMEFUE,GIMMEFAI", function onMessage(message) {
  return "GIMMEDABAJABAZA";
});

// Frame script that runs in the browser
let result = sendSendMessage("GIMMEFUE,GIMMEFAI");
console.log(result[0]);
// Writes to the console: GIMMEDABAJABAZA

From the documentation:

Because a single message can be received by more than one listener, the return value of sendSyncMessage() is an array of all the values returned from every listener, even if it only contains a single value.

I don’t use sync messages from frame scripts a lot, so this was news to me.

You can use [cocoaEvent hasPreciciseScrollingDeltas] to differentiate between scrollWheel events from a mouse and a trackpad

scrollWheel events can come from a standard mouse or a trackpad1. According to this Stack Overflow post, one potential way of differentiating between the scrollWheel events coming from a mouse, and the scrollWheel events coming from a trackpad is by calling:

bool isTrackpad = [theEvent hasPreciseScrollingDeltas];

since mouse scrollWheel is usually line-scroll, whereas trackpads (and Magic Mouse) are pixel scroll.

The srcdoc attribute for iframes lets you easily load content into an iframe via a string

It’s been a while since I’ve done web development, so I hadn’t heard of srcdoc before. It was introduced as part of the HTML5 standard, and is defined as:

The content of the page that the embedded context is to contain. This attribute
is expected to be used together with the sandbox and seamless attributes. If a
browser supports the srcdoc attribute, it will override the content specified in
the src attribute (if present). If a browser does NOT support the srcdoc
attribute, it will show the file specified in the src attribute instead (if
present).

So that’s an easy way to inject some string-ified HTML content into an iframe.

Primitives on IPDL structs are not initialized automatically

I believe this is true for structs in C and C++ (and probably some other languages) in general, but primitives on IPDL structs do not get initialized automatically when the struct is instantiated. That means that things like booleans carry random memory values in them until they’re set. Having spent most of my time in JavaScript, I found that a bit surprising, but I’ve gotten used to it. I’m slowly getting more comfortable working lower-level.

This was the ultimate cause of this crasher bug that dbaron was running into while exercising the e10s printing code on a debug Nightly build on Linux.

This bug was opened to investigate initializing the primitives on IPDL structs automatically.

Networking is ultimately done in the parent process in multi-process Firefox

All network requests are proxied to the parent, which serializes the results back down to the child. Here’s the IPDL protocol for the proxy.

On bi-directional text and RTL

gw280 and I noticed that in single-process Firefox, a <select> dropdown set with dir=”rtl”, containing an <option> with the value “A)” would render the option as “(A”.

If the value was “A) Something else”, the string would come out unchanged.

We were curious to know why this flipping around was happening. It turned out that this is called “BiDi”, and some documentation for it is here.

If you want to see an interesting demonstration of BiDi, click this link, and then resize the browser window to reflow the text. Interesting to see where the period on that last line goes, no?

It might look strange to someone coming from a LTR language, but apparently it makes sense if you’re used to RTL.

I had not known that.

Some terminal spew

Some terminal spew

Now what’s all this?

My friend and colleague Mike Hoye showed me the above screenshot upon coming into work earlier this week. He had apparently launched Nightly from the terminal, and at some point, all that stuff just showed up.

“What is all of that?”, he had asked me.

I hadn’t the foggiest idea – but a quick DXR showed basic_code_modules.cc inside Breakpad, the tool used to generate crash reports when things go wrong.

I referred him to bsmedberg, since that fellow knows tons about crash reporting.

Later that day, mhoye got back to me, and told me that apparently this was output spew from Firefox’s plugin hang detection code. Mystery solved!

So if you’re running Firefox from the terminal, and suddenly see some basic_code_modules.cc stuff show up… a plugin you’re running probably locked up, and Firefox shanked it.


  1. And probably a bunch of other peripherals as well 

Sync Thunderbird with your Google Contacts

There are a bunch of add-ons out there to help you sync Thunderbird with your Google Contacts.

I want to share my favourite one with you.

Simply named, “Google Contacts”, this add-on automatically detects if you have a GMail account in your profile, and does the rest of the heavy lifting for you.

Honestly, it’s as easy as falling off a bike.

Get it here.

So a big thank you to the add-on developer, H. Ogi!

Creating a new Thunderbird Address Book: the feature page, and some literature…

So my dream of redesigning / rebuilding the Thunderbird address book is moving forward.  Here’s the draft feature page.

I also got the Contacts add-on from Labs working (limping, rather) in Thunderbird.  Some very interesting ideas in that add-on.

I’ve also started reading some related work.  Here’s what I’ve been gazing at for the past few days:

  1. Bug 674720 (WebContacts or Contacts+)
  2. The W3C Contacts API draft spec
  3. The PortableContacts draft spec
  4. The vCard spec
  5. The Firefox Sync development documents

So, basically, I’m exposing myself to as much current work in this problem space as possible.  Is there anything else I should be reading?

Thunderbird and Ubuntu One: First Thoughts, First Roadblock (or Prior Art and RDF’d)

Remember my quest to integrate Ubuntu One contacts into Thunderbird?

So I spent a chunk of time over the last day or so looking at prior art – the efforts of others to solve the same problem.  (I’m using “prior art” pretty loosely.  I’m not by any means filing patent claims.)

Prior Art Round-up

The Hedera Project

Hedera is a Thunderbird extension, and probably the most direct solution to the Thunderbird and Ubuntu One integration problem.  With Hedera, all contacts in all address books are sent off to Ubuntu One, with metadata to keep the contacts in the right address books.  Metadata is also included to keep contacts distinct from one Thunderbird profile to the next (if you’re one of the rare users of profiles).

As of late, the extension has gotten a bit dusty – the author, James Tait, is currently working at Canonical, and hasn’t had much time to maintain it.

Despite that, it still does the job pretty well.  I was successfully able to synchronize my contacts to Ubuntu One, which made me fist-pump.  Great work, James!

However, after examining the code, I have a few concerns:

  • The first one that jumps out at me is the reliance upon a shell script to determine the DesktopCouch server port, as well as obtain access credentials.  While effective, I think a more direct approach would be more appropriate.  Perhaps I could develop a DesktopCouch XPCOM service that returns these values?
  • Contacts that are not branded with “Thunderbird” metadata are ignored.  This means that contacts created from the Ubuntu One web interface are not brought into Thunderbird, unless the metadata can somehow be added there.  I didn’t immediately see a way to do this.  This also means that contacts from other applications (I’m looking at you, Evolution) don’t get brought into Thunderbird.
  • Since the contacts are also given profile metadata, it means that I only get those contacts if I share the same profile.  This is problematic if I drop my computer in the river, get a new one, and fire up a copy of Thunderbird:  my profile will be different, so my contacts won’t come in.  They’ll still exist in Ubuntu One’s storage, but won’t come into my Thunderbird profile, unless I modify my profile string to match my old one.

Funambol Mozilla Sync Client

Funambol develops open-source mobile communications sync software, and it looks like Canonical is using Funambol to power their mobile sync services.

Users install the Funambol Mozilla Sync Client, which then syncs contacts with Ubuntu One over the mobile sync service.

It’s not a bad solution, and is the one advocated by the Ubuntu Support pages.

Here are my concerns:

  • According to the support pages, only Thunderbird 2.x is currently supported.  Thunderbird 3.1.9 is the current version in the Ubuntu packages, and the Mozilla Messaging team is working like crazy people on 3.3 (where did 3.2 go?  long story).  Supporting Thunderbird 3 is a BFD.
  • This approach assumes that you’ve got the $3.99 US per month mobile Ubuntu One service.

Now, with respect to that last point, I’m not against paying for stuff.  Money lets companies like Canonical, Funambol (and Mozilla Messaging, for that matter) survive.  But I do think it’s a little silly that Thunderbird needs to pretend to be a mobile phone, and communicate through the mobile sync service.  That’s why I said Hedera was the more direct solution.

If I got any of that wrong, I’m sure someone from Funambol will comment and correct me.  🙂

Bindwood

Bindwood is an extension that allows Mozilla Firefox to synchronize bookmarks via Ubuntu One.  The reason I’m putting this up, is because a lot of good code has been written here to communicate with the DesktopCouch service.  If I resolve a few licensing issues, it might be possible for me to leverage some of that code to make the Thunderbird + Ubuntu One project move faster.

Evolution

Evolution currently has Ubuntu One support built in, thanks to the Evolution-CouchDB project.

Evolution-CouchDB creates a new address book called “Ubuntu One” for every user.  Any contacts that go into that address book are sync’d with Ubuntu One, and any contacts that get added to Ubuntu One get loaded into that address book.

It’s an elegant solution, and addresses the issues I brought up with Hedera.

If I were to implement a similar solution for Thunderbird, it would mean that contacts between Evolution would be seamlessly imported into Thunderbird.  The behaviour would be exactly the same.  Consistency is good.  Consistency means happy users.

Unless I hear compelling argument for something else, I think this the behaviour I’m going to implement.

Mac OSX’s Address Book

Mac OSX has it’s own internal address book, and many Mac-based Thunderbird users were crying out for integration.  A developer named Peter Van der Beken karate-kicked the bug (and may have collected a bug bounty on it…unsure), and now we have OSX address book integration.

The OSX address book integration is very similar to Evolution’s behaviour:  it creates a new address book within Thunderbird, and all contacts from the OSX native address book appear there.

As it stands, this integration is read-only.

Since we’re dealing with OSX, it means Objective-C is the name of the game.  Here’s the code.

Ugh.  Wouldn’t it be awesome to leverage some of the work from Bindwood, Hedera (and maybe Funambol…I haven’t examined their code yet), and implement the Ubuntu One integration all in Javascript?  Yes!  That’d be lovely!

Except for one thing.

RDF

I spent most of yesterday examining this one, and I think I’ve got my head wrapped around it.

So, RDF stands for Resource Description Framework, and it’s a way of representing information in a way so that machines can make useful inferences and queries about that information.  That’s a super-simplified definition.  Here’s something a little more robust.

What does this have to do with Thunderbird and Ubuntu One?

Well, it turns out that the Thunderbird address book interface uses RDF to query / know about the address books that are available.  So, when you pop open the address book manager in Thunderbird, and it populates the list of address books, it’s using RDF to get that information.

So what’s wrong with that?  Well, it means that if I want to add a special “Ubuntu One” address book, it has to register itself with the RDF service as an RDFResource.

There’s two issues there:

  1. Part of RDFResource is not scriptable, which means it’d need to be implemented in C++.  So much for leveraging Bindwood / Hedera / Funambol.
  2. The Thunderbird team knows about the limitations of RDF and are trying to remove it’s usage from Thunderbird. I’d hate to implement all that RDFResource stuff just so it can get tossed out in a few months.

So I might have to really start pushing on RDF removal from the address book.  If I go that route, it means that Ubuntu One synchronization would not be available for anything earlier than Thunderbird 3.3.  Ugh.

Sounds like it’s time for me to discuss this with my superiors.  I’ll let you know what I find out.

My Campaign to get Thunderbird Integrated into Ubuntu Natty Narwhal Continues…

I’ve been silent about my work for a few weeks, which is a shame, because one of the top reasons why I accepted a job with Mozilla Messaging was because I was free to talk about what I was doing.

I’ve been neglecting that right, but only because I’ve been holy shit busy.  I’ve been blitzing my Ubuntu Unity integration work like a MoFo, and have gotten two Thunderbird extensions up on Mozilla Labs:

  1. Messaging Menu integration
  2. Unity Launcher integration

So what’s next?

Ubuntu One

Ubuntu One is a service that allows you to sync things like files, bookmarks and contacts between different computers.  (Incidentally, Mozilla has their own service called Sync to do something similar with bookmarks and passwords.)

That’s a pretty cool idea.  Imagine it – you get a brand new computer, hook it up to Ubuntu One, and blam:  all of your bookmarks and contacts are already there waiting for you.

Currently, however, Thunderbird does not support sharing contacts via Ubuntu One.

And that’s what I’m tackling next.

Ubuntu One Contacts Integration

At this point, my goal is to write an extension that will add a new address book to Thunderbird.  Any contacts that are currently stored and shared via Ubuntu One will appear in that address book.

I’ll deal with adding new contacts later – for now, I’ll just do read-only, to keep the complexity down.

So stay tuned.  Ubuntu One Contacts integration is coming…