Add a hack to avoid crashing when the app window divider is dragged off of the screen on N multi-window

This commit is contained in:
Cameron Gutman 2016-06-18 14:40:42 -07:00
parent 36f8cc02cb
commit a5ca8a7472
2 changed files with 10 additions and 2 deletions

View File

@ -971,6 +971,14 @@ public class Game extends Activity implements SurfaceHolder.Callback,
@Override @Override
public void surfaceDestroyed(SurfaceHolder holder) { public void surfaceDestroyed(SurfaceHolder holder) {
if (connected) { if (connected) {
// HACK: Android is supposed to let you return from this function
// before throwing a fit if you access the surface again. Unfortunately,
// MediaCodec often tries to access the destroyed surface and triggers
// an IllegalStateException. To workaround this, we will invoke
// the DecoderRenderer's stop function ourselves, so it will hopefully
// happen early enough to not trigger the bug
decoderRenderer.stop();
stopConnection(); stopConnection();
} }
} }

View File

@ -475,8 +475,8 @@ public class MediaCodecDecoderRenderer extends EnhancedDecoderRenderer {
} catch (InterruptedException ignored) { } } catch (InterruptedException ignored) { }
} }
// Stop the decoder // We could stop the decoder here, but it seems to cause some problems
videoDecoder.stop(); // so we'll just let release take care of it.
} }
@Override @Override