mozilla

Mozilla Nederland LogoDe Nederlandse
Mozilla-gemeenschap

Mike Conley: On unsafe CPOW usage, and “why is my Nightly so sluggish with e10s enabled?”

Thunderbird - ti, 17/02/2015 - 17:47

If you’ve opened the Browser Console lately while running Nightly with e10s enabled, you might have noticed a warning message – “unsafe CPOW usage” – showing up periodically.

I wanted to talk a little bit about what that means, and what’s being done about it. Brad Lassey already wrote a bit about this, but I wanted to expand upon it (especially since one of my goals this quarter is to get a handle on unsafe CPOW usage in core browser code).

I also wanted to talk about sluggishness that some of our brave Nightly testers with e10s enabled have been experiencing, and where that sluggishness is coming from, and what can be done about it.

What is a CPOW?

“CPOW” stands for “Cross-process Object Wrapper”1, and is part of the glue that has allowed e10s to be enabled on Nightly without requiring a full re-write of the front-end code. It’s also part of the magic that’s allowing a good number of our most popular add-ons to continue working (albeit slowly).

In sum, a CPOW is a way for one process to synchronously access and manipulate something in another process, as if they were running in the same process. Anything that can be considered a JavaScript Object can be represented as a CPOW.

Let me give you an example.

In single-process Firefox, easy and synchronous access to the DOM of web content was more or less assumed. For example, in browser code, one could do this from the scope of a browser window:

let doc = gBrowser.selectedBrowser.contentDocument; let contentBody = doc.body;

Here contentBody corresponds to the <body> element of the document in the currently selected browser. In single-process Firefox, querying for and manipulating web content like this is quick and easy.

In multi-process Firefox, where content is processed and rendered in a completely separate process, how does something like this work? This is where CPOWs come in2.

With a CPOW, one can synchronously access and manipulate these items, just as if they were in the same process. We expose a CPOW for the content document in a remote browser with contentDocumentAsCPOW, so the above could be rewritten as:

let doc = gBrowser.selectedBrowser.contentDocumentAsCPOW; let contentBody = doc.body;

I should point out that contentDocumentAsCPOW and contentWindowAsCPOW are exposed on <xul:browser> objects, and that we don’t make every accessor of a CPOW have the “AsCPOW” suffix. This is just our way of making sure that consumers of the contentWindow and contentDocument on the main process side know that they’re probably working with CPOWs3. contentBody.firstChild would also be a CPOW, since CPOWs can only beget more CPOWs.

So for the most part, with CPOWs, we can continue to query and manipulate the <body> of the document loaded in the current browser just like we used to. It’s like an invisible compatibility layer that hops us right over that process barrier.

Great, right?

Well, not really.

CPOWs are really a crutch to help add-ons and browser code exist in this multi-process world, but they’ve got some drawbacks. Most noticeably, there are performance drawbacks.

Why is my Nightly so sluggish with e10s enabled?

Have you been noticing sluggish performance on Nightly with e10s? Chances are this is caused by an add-on making use of CPOWs (either knowingly or unknowingly). Because CPOWs are used for synchronous reading and manipulation of objects in other processes, they send messages to other processes to do that work, and block the main process while they wait for a response. We call this “CPOW traffic”, and if you’re experiencing a sluggish Nightly, this is probably where the sluggishness if coming from.

Instead of using CPOWs, add-ons and browser code should be updated to use frame scripts sent over the message manager. Frame scripts cannot block the main process, and can be optimized to send only the bare minimum of information required to perform an action in content and return a result.

Add-ons built with the Add-on SDK should already be using “content scripts” to manipulate content, and therefore should inherit a bunch of fixes from the SDK as e10s gets closer to shipping. These add-ons should not require too many changes. Old-style add-ons, however, will need to be updated to use frame scripts unless they want to be super-sluggish and bog the browser down with CPOW traffic.

And what constitutes “unsafe CPOW usage”?

“unsafe” might be too strong a word. “unexpected” might be a better term. Brad Lassey laid this out in his blog post already, but I’ll quickly rehash it.

There are two main cases to consider when working with CPOWs:

  1. The content process is already blocked sending up a synchronous message to the parent process
  2. The content process is not blocked

The first case is what we consider “the good case”. The content process is in a known good state, and its primed to receive IPC traffic (since it’s otherwise just idling). The only bad part about this is the IPC traffic.

The second case is what we consider the bad case. This is when the parent is sending down CPOW messages to the child (by reading or manipulating objects in the content process) when the child process might be off processing other things. This case is far more likely than the first case to cause noticeable performance problems, as the main thread of the content process might be bogged down doing other things before it can handle the CPOW traffic – and the parent will be blocked waiting for the messages to be responded to!

There’s also a more speculative fear that the parent might send down CPOW traffic at a time when it’s “unsafe” to communicate with the content process. There are potentially times when it’s not safe to run JS code in the content process, but CPOWs traffic requires both processes to execute JS. This is a concern that was expressed to me by someone over IRC, and I don’t exactly understand what the implications are – but if somebody wants to comment and let me know, I’ll happily update this post.

So, anyhow, to sum – unsafe CPOW usage is when CPOW traffic is initiated on the parent process side while the content process is not blocked. When this unsafe CPOW usage occurs, we log an “unsafe CPOW usage” message to the Browser Console, along with the script and line number where the CPOW traffic was initiated from.

Measuring

We need to measure and understand CPOW usage in Firefox, as well as add-ons running in Firefox, and over time we need to reduce this CPOW usage. The priority should be on reducing the “unsafe CPOW usage” CPOWs in core browser code.

If there’s anything that working on the Australis project taught me, it’s that in order to change something, you need to know how to measure it first. That way, you can make sure your efforts are having an effect.

We now have a way of measuring the amount of time that Firefox code and add-ons spend processing CPOW messages. You can look at it yourself – just go to about:compartments.

It’s not the prettiest interface, but it’s a start. The second column is the time processing CPOW traffic, and the higher the number, the longer it’s been doing it. Naturally, we’ll be working to bring those numbers down over time.

A possibly quick-fix for a slow Nightly with e10s

As I mentioned, we also list add-ons in about:compartments, so if you’re experiencing a slow Nightly, check out about:compartments and see if there’s an add-on with a high number in the second column. Then, try disabling that add-on to see if your performance problem is reduced.

If so, great! Please file a bug on Bugzilla in this component for the add-on, mention the name of the add-on4, describe the performance problem, and mark it blocking e10s-addons if you can.

We’re hoping to automate this process by exposing some UI that informs the user when an add-on is causing too much CPOW traffic. This will be landing in Nightly near you very soon.

PKE Meter, a CPOW Geiger Counter

Logging “unsafe CPOW usage” is all fine and dandy if you’re constantly looking at the Browser Console… but who is constantly looking at the Browser Console? Certainly not me.

Instead, I whipped up a quick and dirty add-on that plays a click, like a Geiger Counter, anytime “unsafe CPOW usage” is put into the Browser Console. This has already highlighted some places where we can reduce unsafe CPOW usage in core Firefox code – particularly:

  1. The Page Info dialog. This is probably the worse offender I’ve found so far – humongous unsafe CPOW traffic just by opening the dialog, and it’s really sluggish.
  2. Closing tabs. SessionStore synchronously communicates with the content process in order to read the tab state before the tab is closed.
  3. Back / forward gestures, at least on my MacBook
  4. Typing into an editable HTML element after the Findbar has been opened.

If you’re interested in helping me find more, install this add-on5, and listen for clicks. At this point, I’m only interested in unsafe CPOW usage caused by core Firefox code, so you might want to disable any other add-ons that might try to synchronously communicate with content.

If you find an “unsafe CPOW usage” that’s not already blocking this bug, please file a new one! And cc me on it! I’m mconley at mozilla dot com.

  1. I pronounce CPOW as “kah-POW”, although I’ve also heard people use “SEE-pow”. To each his or her own. 

  2. For further reading, Bill McCloskey discusses CPOWs in greater detail in this blog post. There’s also this handy documentation

  3. I say probably, because in the single-process case, they’re not working with CPOWs – they’re accessing the objects directly as they used to. 

  4. And say where to get it from, especially if it’s not on AMO. 

  5. Source code is here 

Categorieën: Mozilla-nl planet

Mike Conley: The Joy of Coding (Episode 1)

Thunderbird - mo, 16/02/2015 - 20:29

Here’s the first episode! I streamed it last Wednesday, and it was mostly concerned with bug 1090439, which is about making the print dialog and progress calls from the child process asynchronous.

Here are the notes for that bug. I still haven’t closed it yet, so perhaps I’ll keep pressing on this next Wednesday when I stream Episode 2. We’ll see!

A note that I did struggle with some resolution issues in this episode. I’m working with Richard Milewski from the Air Mozilla team to make this better for the next episode. Sorry about that!

Categorieën: Mozilla-nl planet

Rumbling Edge - Thunderbird: 2015-02-15 Calendar builds

Thunderbird - mo, 16/02/2015 - 08:22

Common (excluding Website bugs)-specific: (36)

  • Fixed: 603933 – outlook 2007 invitation reply wrong sender
  • Fixed: 1009894 – Update internal timezone database from version 2014b to version 2015a
  • Fixed: 1070491 – Today pane/sidebar: Month and year always “Jan 5555″ on startup
  • Fixed: 1070881 – Running xpcshell tests failing because Lightning directory missing from dist/bin/extensions/
  • Fixed: 1083374 – Calendar xpcshell and mozmill tests failing after OS X signing changes
  • Fixed: 1095119 – Remove Promise.defer usage
  • Fixed: 1101175 – Accepting inviations doesn’t work as expected (403 forbidden)
  • Fixed: 1110881 – Google login popup gives no context
  • Fixed: 1116227 – String shims are defined incorrectly
  • Fixed: 1116305 – Lightning 3.3.2 still speaks only English in TB 31.3.
  • Fixed: 1116882 – calRecurrenceRule tries to set a non-numeric BYMONTHDAY rule
  • Fixed: 1117339 – Thunderbird 24 doesn’t support using Promise as a constructor
  • Fixed: 1117340 – Task lists don’t work for calendar entries without a calendar
  • Fixed: 1117341 – Outdated client message shown when using obsolete token
  • Fixed: 1117540 – useDefault not correctly set if there are no default alarms
  • Fixed: 1117541 – Fix and run xpcshell tests for the provider
  • Fixed: 1120163 – Warning: Property contained reference to invalid variable
  • Fixed: 1120258 – Saving an item in the event dialog fails with MODIFICATION_FAILED if the item has been modified elsewhere
  • Fixed: 1120669 – Details button in imipBar is not always reset
  • Fixed: 1121156 – Converting to event broken for locales without an alphabet
  • Fixed: 1121373 – “Other month” day label in month view have a different color
  • Fixed: 1121415 – Replace timezones.sqlite with a non-binary format
  • Fixed: 1123088 – Label for calendar alarm preview button should be “play”
  • Fixed: 1123207 – Sea Monkey Calendar has disappeared
  • Fixed: 1124152 – Move shims from gdataUtils to shim/ subdirectory
  • Fixed: 1124154 – Wait for parsing to complete before completing synchronization
  • Fixed: 1124640 – Excessive drop-downs and other widths in Lightning’s options – Calendar pane tabs
  • Fixed: 1126338 – Cannot create Google event with addItem() with attendees and no organizer
  • Fixed: 1127247 – Typo in timezone JSON property
  • Fixed: 1128105 – Meeting Accept/Decline buttons not appearing on incoming meeting invitations
  • Fixed: 1128258 – Error in attendee invitation dialog
  • Fixed: 1128293 – TEST-UNEXPECTED-FAIL | xpcshell-icaljs.ini:calendar/test/unit/test_alarmservice.js | test_addItems – [test_addItems : 12] false == true
  • Fixed: 1129094 – [Error: ics-service doesn’t recognize own tzid: floating] [TypeError: aComponent is null] in calTimezoneService.js
  • Fixed: 1129857 – Update timezones to 2015a
  • Fixed: 1130841 – Fix the TodayLabel color for systemcolors
  • Fixed: 1130902 – Notifications are not sent when modifying events

Sunbird will no longer be actively developed by the Calendar team.

Windows builds Official Windows

Linux builds Official Linux (i686), Official Linux (x86_64)

Mac builds Official Mac

Categorieën: Mozilla-nl planet

Rumbling Edge - Thunderbird: 2015-02-15 Thunderbird comm-central builds

Thunderbird - mo, 16/02/2015 - 08:21

Thunderbird-specific: (27)

  • Fixed: 325458 – Recipient Autocomplete: Nickname does not get highest precedence for matching address book entries, for searchphrase==nickname [To, CC, addressing field/area, toplisted, priority, results]
  • Fixed: 526429 – Theme preview should be made branding-aware or branding-agnostic
  • Fixed: 588759 – Make sure status bar messages have proper punctuation
  • Fixed: 742248 – Cannot scroll message window from the input area
  • Fixed: 790539 – Participant list does not update properly while chat tab is inactive
  • Fixed: 926181 – Thunderbird 24 OSX freezes on startup with profile on network drive (AFP)
  • Fixed: 986978 – Add Data Choices Tab to preferences, with GUI option to enable/disable Crash Reporter
  • Fixed: 1084653 – Recipient autocomplete: Increase maximum default number of result entries immediately visible in dropdown from current limit of 4 contacts
  • Fixed: 1085382 – unable to create the phishing warden: [Exception… “Not enough arguments [nsIUrlListManager.registerTable]” nsresult: “0x80570001 (NS_ERROR_XPC_NOT_ENOUGH_ARGS)” location: “JS frame :: file:///REF-OBJ-DIR/objdir-tb3/dist/bin/components/nsPhishingProtec
  • Fixed: 1100330 – ReferenceError: reference to undefined property this._actualWorker in gloda/indexer.js
  • Fixed: 1108251 – Review styling for threadpane icons/columns on all platforms
  • Fixed: 1113863 – Windows 7 Debug failing all tests | Exception: Sorry, cannot connect to jsbridge extension, port 24242
  • Fixed: 1117060 – remove deprecated let expressions in comm-central
  • Fixed: 1117496 – The Chat toolbar don’t use the inverted icons on dark LW-themes
  • Fixed: 1117526 – Selected tab shows bottom border when using LW-theme
  • Fixed: 1118395 – “create filter from message” message header context menu for non-address should trigger only for right click
  • Fixed: 1120136 – C-C: mailnews/local/src/nsPop3Sink.{h,cpp} variable m_inboxOutputStream is no longer used.
  • Fixed: 1120179 – [in-content preferences] orange stripe is missing on main navigation
  • Fixed: 1120181 – [in-content preferences] jumping icon when switching preference category
  • Fixed: 1120183 – [in-content preferences] titles of subcategories are underlined, not in Firefox
  • Fixed: 1121107 – Consider patching mozmill to be able to run in the mozharness virtualenv
  • Fixed: 1121143 – onFolderRemovedFromQ “canceled” undefined (wrong scope)
  • Fixed: 1121566 – TEST-UNEXPECTED-FAIL | dom/presentation/tests/xpcshell/test_presentation_device_manager.js | xpcshell return code: 0
  • Fixed: 1124736 – Move PREF_JS_EXPORTS to moz.build in c-c
  • Fixed: 1126859 – comm-central compilation error: ‘PL_DHashTableLookup’ was not declared in this scope, etc.
  • Fixed: 1127199 – getValidRFC5322Date returns wrong date in some instances.
  • Fixed: 1133022 – Error: …\installer\package-manifest:151: Missing file(s): bin/components/imgicon.xpt

MailNews Core-specific: (22)

  • Fixed: 479823 – archive filter rules: when Archive function is used a special set of filters marked to activate at ‘Archive time’ should be invoked, not the built-in archive function
  • Fixed: 498814 – “Compact Folder” silently fails and deletes .msf, if mail folder file is opened by other software (in the worst case, generates null mail folder file or deletes mail folder file)
  • Fixed: 558659 – Support IMAP LIST SPECIAL-USE (RFC 6154) to autoconfigure Sent, Trash, Draft folders on IMAP servers
  • Fixed: 675448 – “Save as …” multiple mails fails because of long pathnames and doesn’t notice the user
  • Fixed: 771643 – deleting or moving messages doesn’t delete messages from the filesystem when using Maildir Lite(IMAP. No way to expunge/delete files under cur as offline-store file when maildirstore, because “Compact” is completely killed by maldirstore even though IMAP)
  • Fixed: 847183 – After new account has been added in the account manager, it doesn’t show up there until closing and reopening it, only directly visible in folder pane
  • Fixed: 854798 – Compacting Berkeley Mbox file changes messageKey (to new MsgOffset after compact), causing dataloss/privacy problems (bug 817245 / bug 799450, bug 766495) due to current design problem of MsgKey=MsgOffset (for Berkeley Mbox files)
  • Fixed: 894012 – convert expungedBytes to 64bit
  • Fixed: 912216 – Temporarily disable CONDSTORE support for many “GMail IMAP + Thunderbird/SeaMonkey” users
  • Fixed: 934170 – mozilla/mach xpcshell-test does not work for comm-central
  • Fixed: 964024 – mozTXTToHTMLConv should never convert content inside <style>, <script>, <head> tags
  • Fixed: 1113275 – Make tests dependent on imapPump work with maildir
  • Fixed: 1117199 – reset mailnews.send_default_charset and mailnews.view_default_charset if they had values no longer supported
  • Fixed: 1118027 – fix some compile warnings in compose/src/nsMsgSend.cpp
  • Fixed: 1120067 – RSS (2.0?) feeds not updating and not being added.
  • Fixed: 1121482 – Remove PL_DHashTableOperate from comm-central
  • Fixed: 1121488 – port changes from bug 1120476 and bug 1121304 to comm-central
  • Fixed: 1122346 – Check if draft message is in db before deleting
  • Fixed: 1123117 – fixIterator should support for-of iteration
  • Fixed: 1124118 – Follow up nsIProgressEventSink.onProgress and nsITransport.onTransportStatus changes by bug 1116867
  • Fixed: 1125672 – PROCESS-CRASH | mailnews/imap/test/unit/test_mailboxes.js | application crashed [@ nsWeakReference::Release()]
  • Fixed: 1132271 – Port bug 1001332 to comm-beta to allow xp to work in Thunderbird beta 36

Windows builds Official Windows, Official Windows installer

Linux builds Official Linux (i686), Official Linux (x86_64)

Mac builds Official Mac

Categorieën: Mozilla-nl planet

Meeting Notes: Thunderbird: 2015-02-10

Thunderbird - wo, 11/02/2015 - 05:00

Thunderbird meeting notes 2015-02-10. Previous meetings: https://wiki.mozilla.org/Thunderbird/StatusMeetings#Meeting_Notes

Attendees

aceman, cloep, florian, jcranmer, Jorg K, mkmelin, Paneglab, rkent, Roland, sshagarwal, wsmwk, MakeMyDay

Action items from last meetings
  • wsmwk to get in touch with Standard8 re: beta.
    • done – bkerensa and sylvestre are on it
  • rkent to work with Standard8 (and Fallen) on issues of 1.management of tracking flags and 2. pushing into aurora and beta for TB 38. (meeting generally agreed that mkmelin and rkent would be appropriate to manage pushing patches forward into aurora and beta).
Critical Issues

Critical bugs. Please leave these here until they’re confirmed fixed.

  • Auto-complete improvements – some of those could go into esr31

Release Issues

  • Current beta blocked due to Windows XP failures. rkent has try server configuration that can test a beta build, and will try Standard8’s suggestions.
Upcoming
  • Thunderbird 38 moves to Earlybird ~ February 24, 2015

We need people to commit to being mentors.

Lightning to Thunderbird Integration

See https://calendar.etherpad.mozilla.org/thunderbird-integration

  • As underpass has pointed out repeatedly (thanks for your patience!) , we need to rewrite / heavily modify the lightning articles on support.mozilla.org. let me know irc: rolandtanglao on #tb-support-crew or rtanglao AT mozilla.com OR simply start editing the articles
Round Table JosiahOne
  • So I started a new job recently, but because of that plus school, my time for TB stuff is very, very low. I will continue doing ui-reviews and reviews, but implementing anything has pretty much come to an end until summer break.
wsmwk
  • release management https://etherpad.mozilla.org/XxBwrpMHKz
  • disable HWA for 38? it has been suggested by someone in support to disable because “3d acceleration … does little or nothing for Thunderbird but messes menus, font and causes crashes (the kind with no crash reporter reports).” bug 1131879
rkent
  • Hot bugs
    • bug 1125577 – startup crash in NSSCryptoContext_FindCertificateByEncodedCertificate (and similar bug 1128614)
    • bug 1124015 – Add UI to select maildir for storage when creating accounts
    • bug 1119529 – Sending message succeeds but Error “error while running message filters on it.”
  • Unfortunately a long review queue that I will be looking at for the next few days.
  • I now have access to Thunderbird ADI data. Our ADI reached a new peak last month (in spite of SlashDot assuming “Thunderbird usage is dropping”) and Japan has now surpassed US as #2 country (after Germany).
jcranmer
  • Hopefully going to work down my review queue by this weekend
  • Main jsmime perf regression fixes are r? rkent
  • I have a non-promisified version of OAuth2, but still no UI hookup
  • Mozharness-based mozmill tests: I’ve updated the runner, need to make updates to three or four repositories to make it work
    • Trying to get this in progress for Thunderbird 38, so we don’t need to maintain the old mozmill buildbot stuff for ESR
  • I’ve been doing some work with the emailjs team to add functionality to their SMTP libraries (specifically with regards to SASL) that we could share between TB/Whiteout.io/Gaia email teams.
TheOne Jorg K

I have an XP machine (32 bit), I could run (not build) and debug (with WinDbg) the beta, if that’s of any help. I’d need to know where do download it … and the mentioned suggestions to try. (Contact via e-mail to start off).

mkmelin
  • autocomplete:
    • the critical regressions fixed
    • 3 prominent complaints still not done: the “tab too quickly doesn’t complete”, “show as red even if found”, “insert link missing paste url in context menu”
    • ordering: now landed on esr, some complaints still, need to investigate
Question Time

I’d like to know what happened to the “Thunderbird Discussions with Mozilla”, ie. the letter that was meant to be sent to the Mozilla management, re. funding, donations, staffing, etc. There was a lively discussion on the tb-planning mailing list in early January 2015.

  • won’t happen before 38 branching
Support team
  • As underpass has pointed out, we need to rewrite all the Lightning articles, they are out of date whether or not we finish the integration for TB 38. email me or irc roland or just edit the articles (see above under “Lightning to Thunderbird integration”. Tonnes do you have time to write some of these Lightning articles in English?
Other
  • Note – meeting notes must be copied from etherpad to wiki before 5AM CET next day so that they will go public in the meeting notes blog.

(Extra) Meeting next Tuesday, Feb 17.

Action Items

-none-

Retrieved from “https://wiki.mozilla.org/index.php?title=Thunderbird/StatusMeetings/2015-02-10&oldid=1055270

Categorieën: Mozilla-nl planet

Bryan Clark: If writing is a muscle

Thunderbird - ti, 10/02/2015 - 08:07

I haven’t been to the gym in a long time.

David Eaves, a person I have immense amounts of respect for, has been using a tag line related to this title/intro on his blog for quite a while, probably longer than I’ve known him.  And I honestly never gave much thought to the idea that writing really is a muscle until recently. I’ve taken a break from being a designer (or a programmer) to work as a product manager for over a year now. Designing and coding require a set of skills I’m very familiar with, code is an interpretive language that people use to communicate with each other about the details of commands they issue a computer. While design is a more visual language of storytelling, heavily using imagery and some text to convey the journey of a user to the team intent on correctly interacting with that user.  Both pursuits are about communication but each uses written language in a very different way.  As a product manager I’m forced to lean on my skills as a writer and I don’t think I had much in the way of skills previously but whatever bedridden muscles have been dormant are reawakening as I realize how young and foolish I really was to ignore this essential form of communication.

I’m hoping there is more to come, perhaps starting with some tech posts about recent projects while I try to grapple with this idea of writing more than a tweet.

Categorieën: Mozilla-nl planet

Mark Banner: Firefox Hello Desktop: Behind the Scenes – Flux and React

Thunderbird - mo, 09/02/2015 - 21:49

This is the first of a few posts that I’m planning regarding discussion about how we implement and work on the desktop and standalone parts of Firefox Hello. We’ve been doing some things in different ways, which we have found to be advantageous. We know other teams are interested in what we do, so its time to share!

Content Processes

First, a little bit of architecture: The panels and conversation window run in content processes (just like regular web pages). The conversation window shares code with the link-clicker pages that are on hello.firefox.com.

Hence those parts run very much in a web-style, and for various reasons, we decided to create them in a web-style manner. As a result, we’ve ended up with using React and Flux to aid our development.

I’ll detail more about the architecture in future posts.

The Flux Pattern

Flux is a recommended pattern for use alongside React, although I think you could use it with other frameworks as well. I’ll detail here about how we use Flux specifically for Hello. As Flux is a pattern, there’s no one set standard and the methods of implementation vary.

Flux Overview

The main parts of a flux system are stores, components and actions. Some of this is a bit like an MVC system, but I find there’s better definition about what does what.
Diagram of Example flow in a Flux patternAn action is effectively a result of an event, that changes the system. For example, in Loop, we use actions for user events, but we also use them for any data incoming from the server.

A store contains the business logic. It listens to actions, when it receives one, it does something based on the action and updates its state appropriately.

A component is a view. The view has a set of properties (passed in values) and/or state (the state is obtained from the store’s state). For a given set of properties and state, you always get the same layout. The components listen for updates to the state in the stores and update appropriately.

We also have a dispatcher. The dispatcher dispatches actions to interested stores. Only one action can be processed at any one time. If a new action comes in, then the dispatcher queues it.

Actions are always synchronous – if changes would happen due to external stimuli then these will be new actions. For example, this prevents actions from blocking other actions whilst waiting for a response from the server.

What advantages do we get?

For Hello, we find the flux pattern fits very nicely. Before, we used a traditional MVC model, however, we kept on getting in a mess with events being all over the place, and application logic being wrapped in amongst the views as well as the models.

Now, we have a much more defined structure:

  • Components/views are a place for displaying, there’s some logic about what to display, but it isn’t business logic.
  • The business logic exists in the stores, and is triggered by actions.
  • You can follow an action through and find out which stores listen for it, and what they do.
  • Actions themselves are well-defined with specified parameters.

React provides the component structure, it has defined ways of tracking state and properties, and the re-rendering on state change gives much automation. Since it encourages the separation of immutable properties, a whole class of inadvertent errors is eliminated.

There’s also many advantages with debugging – we have a flag that lets us watch all the actions going through the system, so its much easier to track what events are taking place and the data passed with them. This combined with the fact that actions have limited scope, helps with debugging the data flows.

Simple Unit Testing

For testing, we’re able to do unit testing in a much simpler fashion:

  • Components/Views are tested by setting up their state and/or properties and ensuring the correct elements are displayed:
it("should render a muted local audio button", function() { var comp = TestUtils.renderIntoDocument( React.createElement(sharedViews.MediaControlButton, { scope: "local", type: "audio", action: function(){}, enabled: false })); expect(comp.getDOMNode().classList.contains("muted")).eql(true); });
  • Stores are tested by setting an initial state, sending an action, and checking the resultant state:
it("should set the state to READY", function() { store.setupRoomInfo(new sharedActions.SetupRoomInfo(fakeRoomInfo)); expect(store._storeState.roomState).eql(ROOM_STATES.READY); });

We therefore have many tests written at the unit test level. Many times we’ve found and prevented issues whilst writing these tests, and yet, because these are all content based, we can run the tests in a few seconds. I’ll go more into testing in a future post.

References

Here’s a few references to some of the areas in our code base that are good example of our flux implementation. Note that behind the scenes, everything is known as Loop – the codename for the project.

Conclusion and more coming…

We’ve found using the flux model is much more organised than we were with an MVC, possibly its just a better defined methodology, but it gave us the structure we badly missing. In future posts, I’ll discuss about our development facilities, more about the desktop architecture and whatever else comes up, so please do leave questions in the comments and I’ll try and answer them either direct or with more posts.

Categorieën: Mozilla-nl planet

Mike Conley: The Joy of Coding (or, Firefox Hacking Live!)

Thunderbird - snein, 08/02/2015 - 20:58

A few months back, I started publishing my bug notes online, as a way of showing people what goes on inside a Firefox engineer’s head while fixing a bug.

This week, I’m upping the ante a bit: I’m going to live-hack on Firefox for an hour and a half for the next few Wednesday’s on Air Mozilla. I’m calling it The Joy of Coding1. I’ll be working on real Firefox bugs2 – not some toy exercise-bug where I’ve pre-planned where I’m going. It will be unscripted, unedited, and uncensored. But hopefully not uninteresting3!

Anyhow, the first episode airs this Wednesday. I’ll be using #livehacking on irc.mozilla.org as a backchannel. Not sure what bug(s) I’ll be hacking on – I guess it depends on what I get done on Monday and Tuesday.

Anyhow, we’ll try it for a few weeks to see if folks are interested in watching. Who knows, maybe we can get a few more developers doing this too – I’d enjoy seeing what other folks do to fix their bugs!

Anyhow, I hope to see you there!

  1. Maybe I’ll wear an afro wig while I stream 

  2. Specifically, I’ll be working on Electrolysis bugs, since that’s what my focus is on these days. 

  3. I’ve actually piloted this for the past few weeks, streaming on YouTube Live. Here’s a playlist of the pilot episodes

Categorieën: Mozilla-nl planet

Rumbling Edge - Thunderbird: 2015-01-14 Calendar builds

Thunderbird - to, 15/01/2015 - 08:52

Common (excluding Website bugs)-specific: (16)

  • Fixed: 432675 – Revise layout of Alarms option pane in preference dialog
  • Fixed: 639284 – Metadata of “Provider for Google Calendar” extension are not translated at AMO
  • Fixed: 909183 – calIDateTime.compare returns incorrect result with floating timezone
  • Fixed: 941425 – Yearly rule “Last day of a month” can’t be set with the UI and is wrongly displayed in the views.
  • Fixed: 958978 – Yearly recurrences with BYMONTH and more BYDAY are displayed wrongly if the last day of the month is not displayed in the view
  • Fixed: 985114 – Make use of CSS variables
  • Fixed: 1072815 – Multiple locales were missing in Lightning 3.3.1 release
  • Fixed: 1080659 – Converting email into task/event fails when localization uses regular expression special characters
  • Fixed: 1082286 – [icaljs] Date/Time Picker seems to have a timezone error
  • Fixed: 1107388 – No auth prompt is shown when subscribing to CalDAV calendars [domWin.document is null]
  • Fixed: 1112502 – Right clicking on a recurring event, and bringing up the attendance sub-menu gives unreadable titles
  • Fixed: 1114504 – Extra localization notes for bug 493389 – Provider for Google Calendar cannot sync tasks
  • Fixed: 1115965 – Provide filename and line number in cal.WARN and cal.ERROR
  • Fixed: 1117324 – Improve stack trace for calListenerBag
  • Fixed: 1117456 – Run unit tests on ical.js as well as libical
  • Fixed: 1118489 – promisifyCalendar mis-invokes Proxy constructor

Sunbird will no longer be actively developed by the Calendar team.

Windows builds Official Windows

Linux builds Official Linux (i686), Official Linux (x86_64)

Mac builds Official Mac

Categorieën: Mozilla-nl planet

Pages