Bug 1394580 - 5. Lazy-load Task.jsm in Messaging.jsm; r=esawin
☠☠ backed out by 96b5a734399c ☠ ☠
authorJim Chen <nchen@mozilla.com>
Tue, 05 Sep 2017 15:27:36 -0400
changeset 428509 1cc1955d6af318c6d57e483b70618a6f59e52681
parent 428508 a9b1cbbeea9adc3666faad75c6a4b9868da09252
child 428510 f069f3c695977904c4b2dda44a5218efe17d28b5
push id7761
push userjlund@mozilla.com
push dateFri, 15 Sep 2017 00:19:52 +0000
treeherdermozilla-beta@c38455951db4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersesawin
bugs1394580
milestone57.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1394580 - 5. Lazy-load Task.jsm in Messaging.jsm; r=esawin We're not lazy-loading Task.jsm in Messaging.jsm right now (despite declaring it through XPCOMUtils.defineLazyModuleGetter) because we unnecessarily reference `Task` when Messaging.jsm is loading. This patch makes us load Task.jsm only when `Task` is really needed. MozReview-Commit-ID: 9rrnLQLaW4y
mobile/android/modules/geckoview/Messaging.jsm
--- a/mobile/android/modules/geckoview/Messaging.jsm
+++ b/mobile/android/modules/geckoview/Messaging.jsm
@@ -191,30 +191,30 @@ DispatcherDelegate.prototype = {
 
     this._requestHandler.listeners[event] = undefined;
     this.unregisterListener(this._requestHandler, event);
   },
 
   _requestHandler: {
     listeners: {},
 
-    onEvent: Task.async(function* (event, data, callback) {
-      try {
-        let response = yield this.listeners[event](data.data);
+    onEvent: function(event, data, callback) {
+      let self = this;
+      Task.spawn(function*() {
+        return yield self.listeners[event](data.data);
+      }).then(response => {
         callback.onSuccess(response);
-
-      } catch (e) {
+      }, error => {
         Cu.reportError("Error in Messaging handler for " + event + ": " + e);
-
         callback.onError({
           message: e.message || (e && e.toString()),
           stack: e.stack || Components.stack.formattedStack,
         });
-      }
-    }),
+      });
+    },
   },
 };
 
 var EventDispatcher = {
   instance: new DispatcherDelegate(IS_PARENT_PROCESS ? Services.androidBridge : undefined),
 
   for: function(aWindow) {
     let view = aWindow && aWindow.arguments && aWindow.arguments[0] &&