A few fixes for decoder crash notifications

This commit is contained in:
Cameron Gutman 2017-09-09 18:44:06 -07:00
parent fd2421618a
commit 38a6a2b74a
4 changed files with 40 additions and 22 deletions

View File

@ -231,7 +231,8 @@ public class Game extends Activity implements SurfaceHolder.Callback,
// We must use commit because the app will crash when we return from this function // We must use commit because the app will crash when we return from this function
tombstonePrefs.edit().putInt("CrashCount", tombstonePrefs.getInt("CrashCount", 0) + 1).commit(); tombstonePrefs.edit().putInt("CrashCount", tombstonePrefs.getInt("CrashCount", 0) + 1).commit();
} }
}); },
tombstonePrefs.getInt("CrashCount", 0));
// Display a message to the user if H.265 was forced on but we still didn't find a decoder // Display a message to the user if H.265 was forced on but we still didn't find a decoder
if (prefConfig.videoFormat == PreferenceConfiguration.FORCE_H265_ON && !decoderRenderer.isHevcSupported()) { if (prefConfig.videoFormat == PreferenceConfiguration.FORCE_H265_ON && !decoderRenderer.isHevcSupported()) {
@ -465,11 +466,6 @@ public class Game extends Activity implements SurfaceHolder.Callback,
// Destroy the capture provider // Destroy the capture provider
inputCaptureProvider.destroy(); inputCaptureProvider.destroy();
// Clear the tombstone count
if (tombstonePrefs.getInt("CrashCount", 0) != 0) {
tombstonePrefs.edit().putInt("CrashCount", 0).apply();
}
} }
@Override @Override
@ -511,6 +507,11 @@ public class Game extends Activity implements SurfaceHolder.Callback,
if (message != null) { if (message != null) {
Toast.makeText(this, message, Toast.LENGTH_LONG).show(); Toast.makeText(this, message, Toast.LENGTH_LONG).show();
} }
// Clear the tombstone count
if (tombstonePrefs.getInt("CrashCount", 0) != 0) {
tombstonePrefs.edit().putInt("CrashCount", 0).apply();
}
} }
finish(); finish();

View File

@ -167,19 +167,28 @@ public class PcView extends Activity implements AdapterFragmentCallbacks {
SharedPreferences prefs = getSharedPreferences("DecoderTombstone", 0); SharedPreferences prefs = getSharedPreferences("DecoderTombstone", 0);
int crashCount = prefs.getInt("CrashCount", 0); int crashCount = prefs.getInt("CrashCount", 0);
if (crashCount == 3) { int lastNotifiedCrashCount = prefs.getInt("LastNotifiedCrashCount", 0);
// At 3 consecutive crashes, we'll forcefully reset their settings
PreferenceConfiguration.resetStreamingSettings(this); // Remember the last crash count we notified at, so we don't
Dialog.displayDialog(this, // display the crash dialog every time the app is started until
getResources().getString(R.string.title_decoding_reset), // they stream again
getResources().getString(R.string.message_decoding_reset), if (crashCount != 0 && crashCount != lastNotifiedCrashCount) {
false); if (crashCount % 3 == 0) {
} // At 3 consecutive crashes, we'll forcefully reset their settings
else if (crashCount >= 1) { PreferenceConfiguration.resetStreamingSettings(this);
Dialog.displayDialog(this, Dialog.displayDialog(this,
getResources().getString(R.string.title_decoding_error), getResources().getString(R.string.title_decoding_reset),
getResources().getString(R.string.message_decoding_error), getResources().getString(R.string.message_decoding_reset),
false); false);
}
else {
Dialog.displayDialog(this,
getResources().getString(R.string.title_decoding_error),
getResources().getString(R.string.message_decoding_error),
false);
}
prefs.edit().putInt("LastNotifiedCrashCount", crashCount).apply();
} }
} }

View File

@ -49,6 +49,8 @@ public class MediaCodecDecoderRenderer extends VideoDecoderRenderer {
private SurfaceHolder renderTarget; private SurfaceHolder renderTarget;
private volatile boolean stopping; private volatile boolean stopping;
private CrashListener crashListener; private CrashListener crashListener;
private boolean reportedCrash;
private int consecutiveCrashCount;
private boolean needsBaselineSpsHack; private boolean needsBaselineSpsHack;
private SeqParameterSet savedSps; private SeqParameterSet savedSps;
@ -111,11 +113,13 @@ public class MediaCodecDecoderRenderer extends VideoDecoderRenderer {
this.renderTarget = renderTarget; this.renderTarget = renderTarget;
} }
public MediaCodecDecoderRenderer(int videoFormat, int bitrate, boolean batterySaver, CrashListener crashListener) { public MediaCodecDecoderRenderer(int videoFormat, int bitrate, boolean batterySaver,
CrashListener crashListener, int consecutiveCrashCount) {
//dumpDecoders(); //dumpDecoders();
this.bitrate = bitrate; this.bitrate = bitrate;
this.crashListener = crashListener; this.crashListener = crashListener;
this.consecutiveCrashCount = consecutiveCrashCount;
// Disable spinner threads in battery saver mode // Disable spinner threads in battery saver mode
if (batterySaver) { if (batterySaver) {
@ -320,7 +324,10 @@ public class MediaCodecDecoderRenderer extends VideoDecoderRenderer {
// This isn't the first time we've had an exception processing video // This isn't the first time we've had an exception processing video
if (System.currentTimeMillis() - initialExceptionTimestamp >= EXCEPTION_REPORT_DELAY_MS) { if (System.currentTimeMillis() - initialExceptionTimestamp >= EXCEPTION_REPORT_DELAY_MS) {
// It's been over 3 seconds and we're still getting exceptions. Throw the original now. // It's been over 3 seconds and we're still getting exceptions. Throw the original now.
crashListener.notifyCrash(initialException); if (!reportedCrash) {
reportedCrash = true;
crashListener.notifyCrash(initialException);
}
throw initialException; throw initialException;
} }
} }
@ -916,6 +923,7 @@ public class MediaCodecDecoderRenderer extends VideoDecoderRenderer {
str += "AVC Decoder: "+((renderer.avcDecoder != null) ? renderer.avcDecoder.getName():"(none)")+"\n"; str += "AVC Decoder: "+((renderer.avcDecoder != null) ? renderer.avcDecoder.getName():"(none)")+"\n";
str += "HEVC Decoder: "+((renderer.hevcDecoder != null) ? renderer.hevcDecoder.getName():"(none)")+"\n"; str += "HEVC Decoder: "+((renderer.hevcDecoder != null) ? renderer.hevcDecoder.getName():"(none)")+"\n";
str += "Build fingerprint: "+Build.FINGERPRINT+"\n"; str += "Build fingerprint: "+Build.FINGERPRINT+"\n";
str += "Consecutive crashes: "+renderer.consecutiveCrashCount+"\n";
str += "Initial video dimensions: "+renderer.initialWidth+"x"+renderer.initialHeight+"\n"; str += "Initial video dimensions: "+renderer.initialWidth+"x"+renderer.initialHeight+"\n";
str += "FPS target: "+renderer.refreshRate+"\n"; str += "FPS target: "+renderer.refreshRate+"\n";
str += "Bitrate: "+renderer.bitrate+" Mbps \n"; str += "Bitrate: "+renderer.bitrate+" Mbps \n";

View File

@ -48,7 +48,7 @@
Using remote desktop software can also cause this error. Try rebooting your machine or reinstalling GFE. Using remote desktop software can also cause this error. Try rebooting your machine or reinstalling GFE.
</string> </string>
<string name="title_decoding_error">Video Decoder Crashed</string> <string name="title_decoding_error">Video Decoder Crashed</string>
<string name="message_decoding_error">Moonlight has crashed due to a issue with this device\'s video decoder. Try adjusting the streaming settings if the crashes continue.</string> <string name="message_decoding_error">Moonlight has crashed due to a problem with this device\'s video decoder. Try adjusting the streaming settings if the crashes continue.</string>
<string name="title_decoding_reset">Video Settings Reset</string> <string name="title_decoding_reset">Video Settings Reset</string>
<string name="message_decoding_reset">Your device\'s video decoder continues to crash at your selected streaming settings. Your streaming settings have been reset to default.</string> <string name="message_decoding_reset">Your device\'s video decoder continues to crash at your selected streaming settings. Your streaming settings have been reset to default.</string>