Bug 1410218 - Fix NPE when cast fails. r=jchen, a=lizzard
authorPetru Lingurar <petru.lingurar@softvision.ro>
Fri, 03 Aug 2018 13:26:55 +0300
changeset 480845 bc58af8e34e6241b613f6f6367eed16ad8113124
parent 480844 b9bf6fef15c756bdd44efc0f6d7f3c99cc591c11
child 480846 7b9c3989046bc01299dab53dd4bea2aff6c17ef1
push id1757
push userffxbld-merge
push dateFri, 24 Aug 2018 17:02:43 +0000
treeherdermozilla-release@736023aebdb1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjchen, lizzard
Bug 1410218 - Fix NPE when cast fails. r=jchen, a=lizzard This happened whenever starting to cast a video and loading the media failed. MediaStatus in this case would be null and querying it would throw a NullPointerException. Avoiding this query when the MediaStatus is null lets the normal execution flow continue and if loading media failed casting will fail gracefully. MozReview-Commit-ID: 8ZOqr1FO1Dt
--- a/mobile/android/base/java/org/mozilla/gecko/ChromeCastPlayer.java
+++ b/mobile/android/base/java/org/mozilla/gecko/ChromeCastPlayer.java
@@ -81,16 +81,20 @@ class ChromeCastPlayer implements GeckoM
             this.title = title;
             this.callback = callback;
         public void onStatusUpdated() {
             MediaStatus mediaStatus = remoteMediaPlayer.getMediaStatus();
+            if (mediaStatus == null) {
+                return;
+            }
             switch (mediaStatus.getPlayerState()) {
             case MediaStatus.PLAYER_STATE_PLAYING:
                 EventDispatcher.getInstance().dispatch("MediaPlayer:Playing", null);
             case MediaStatus.PLAYER_STATE_PAUSED:
                 EventDispatcher.getInstance().dispatch("MediaPlayer:Paused", null);
             case MediaStatus.PLAYER_STATE_IDLE: