Bug 1357287 - [1.1] Catch and ignore runtime exception during media codec query. r=snorp
authorEugen Sawin <esawin@mozilla.com>
Tue, 18 Apr 2017 19:30:41 +0200
changeset 353990 72812cf49ddfb2203118986fca36c8048fb54918
parent 353989 bf8468e259dce509bfe0c4cc51874a0797932e36
child 353991 31e942586dd8e73f1744e412be92db1634420525
push id31684
push usercbook@mozilla.com
push dateThu, 20 Apr 2017 09:13:26 +0000
treeherdermozilla-central@27311156637f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssnorp
bugs1357287
milestone55.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 1357287 - [1.1] Catch and ignore runtime exception during media codec query. r=snorp
mobile/android/geckoview/src/main/java/org/mozilla/gecko/util/HardwareCodecCapabilityUtils.java
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/util/HardwareCodecCapabilityUtils.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/util/HardwareCodecCapabilityUtils.java
@@ -35,17 +35,25 @@ public final class HardwareCodecCapabili
     CodecCapabilities.COLOR_FormatYUV420Planar,
     CodecCapabilities.COLOR_FormatYUV420SemiPlanar,
     CodecCapabilities.COLOR_QCOM_FormatYUV420SemiPlanar,
     COLOR_QCOM_FORMATYUV420PackedSemiPlanar32m
   };
 
   @WrapForJNI
   public static boolean findDecoderCodecInfoForMimeType(String aMimeType) {
-    for (int i = 0; i < MediaCodecList.getCodecCount(); ++i) {
+    int numCodecs = 0;
+    try {
+      numCodecs = MediaCodecList.getCodecCount();
+    } catch (final RuntimeException e) {
+      Log.e(LOGTAG, "Failed to retrieve media codec count", e);
+      return false;
+    }
+
+    for (int i = 0; i < numCodecs; ++i) {
       MediaCodecInfo info = MediaCodecList.getCodecInfoAt(i);
       if (info.isEncoder()) {
         continue;
       }
       for (String mimeType : info.getSupportedTypes()) {
         if (mimeType.equals(aMimeType)) {
           return true;
         }