Bug 1061032 - Crash in java.lang.NullPointerException: at org.mozilla.gecko.ChromeCast$2.onConnected(ChromeCast.java). r=mfinkle, a=lmandel
authorwesj <wjohnston@mozilla.com>
Thu, 02 Oct 2014 11:27:00 -0700
changeset 225640 057a88b514d591f620e75befc31b36ca48cee3f5
parent 225639 41199adb9b7064da2cf2be2919bc412a7b3c724f
child 225641 f5ec4ead72da5939a9df694bf2c6a29062254ea2
push id3979
push userraliiev@mozilla.com
push dateMon, 13 Oct 2014 16:35:44 +0000
treeherdermozilla-beta@30f2cc610691 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle, lmandel
bugs1061032
milestone34.0a2
Bug 1061032 - Crash in java.lang.NullPointerException: at org.mozilla.gecko.ChromeCast$2.onConnected(ChromeCast.java). r=mfinkle, a=lmandel
mobile/android/base/ChromeCast.java
--- a/mobile/android/base/ChromeCast.java
+++ b/mobile/android/base/ChromeCast.java
@@ -188,17 +188,18 @@ class ChromeCast implements GeckoMediaPl
             public void onApplicationDisconnected(int errorCode) { }
         });
 
         apiClient = new GoogleApiClient.Builder(context)
             .addApi(Cast.API, apiOptionsBuilder.build())
             .addConnectionCallbacks(new GoogleApiClient.ConnectionCallbacks() {
                 @Override
                 public void onConnected(Bundle connectionHint) {
-                    if (!apiClient.isConnected()) {
+                    // Sometimes apiClient is null here. See bug 1061032
+                    if (apiClient != null && !apiClient.isConnected()) {
                         debug("Connection failed");
                         callback.sendError("Not connected");
                         return;
                     }
 
                     // Launch the media player app and launch this url once its loaded
                     try {
                         Cast.CastApi.launchApplication(apiClient, CastMediaControlIntent.DEFAULT_MEDIA_RECEIVER_APPLICATION_ID, true)
@@ -423,17 +424,18 @@ class ChromeCast implements GeckoMediaPl
                 public void onApplicationDisconnected(int errorCode) { }
             });
 
         apiClient = new GoogleApiClient.Builder(context)
             .addApi(Cast.API, apiOptionsBuilder.build())
             .addConnectionCallbacks(new GoogleApiClient.ConnectionCallbacks() {
                     @Override
                     public void onConnected(Bundle connectionHint) {
-                        if (!apiClient.isConnected()) {
+                        // Sometimes apiClient is null here. See bug 1061032
+                        if (apiClient == null || !apiClient.isConnected()) {
                             return;
                         }
 
                         // Launch the media player app and launch this url once its loaded
                         try {
                             Cast.CastApi.launchApplication(apiClient, MIRROR_RECIEVER_APP_ID, true)
                                 .setResultCallback(new MirrorCallback(callback));
                         } catch (Exception e) {