diff --git a/java/AndroidManifest.xml.in b/java/AndroidManifest.xml.in index e79fb4e46e7..f2aede7369c 100644 --- a/java/AndroidManifest.xml.in +++ b/java/AndroidManifest.xml.in @@ -77,10 +77,14 @@ along with GNU Emacs. If not, see . --> @ANDROID_SHARED_USER_ID@ android:extractNativeLibs="true"> + + @@ -173,6 +177,7 @@ along with GNU Emacs. If not, see . --> = Build.VERSION_CODES.HONEYCOMB) + { + flag = WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED; + window = dialog.getWindow (); + window.addFlags (flag); + } + return dialog; } diff --git a/java/org/gnu/emacs/EmacsSurfaceView.java b/java/org/gnu/emacs/EmacsSurfaceView.java index 3f62af4ab99..54fe70e1634 100644 --- a/java/org/gnu/emacs/EmacsSurfaceView.java +++ b/java/org/gnu/emacs/EmacsSurfaceView.java @@ -176,7 +176,25 @@ else if (bitmap != null) onDraw (Canvas canvas) { /* Paint the view's bitmap; the bitmap might be recycled right - now. */ + now. + + Hardware acceleration is disabled in AndroidManifest.xml to + prevent Android from uploading the front buffer to the GPU from + a separate thread. This is important for two reasons: first, + the GPU command queue uses a massive amount of memory (dozens + of MiB) to upload bitmaps to the GPU, regardless of how much of + the bitmap has actually changed. + + Secondly, asynchronous texturization leads to race conditions + when a buffer swap occurs before the front buffer is fully + uploaded to the GPU. Normally, only slight and tolerable + tearing should result from this behavior, but Android does not + properly interlock the ``generation ID'' used to avoid + texturizing unchanged bitmaps with the bitmap contents, + consequentially leading to textures in an incomplete state + remaining in use to the GPU if a buffer swap happens between + the image data being uploaded and the ``generation ID'' being + read. */ if (frontBuffer != null) canvas.drawBitmap (frontBuffer, 0f, 0f, uiThreadPaint); diff --git a/java/org/gnu/emacs/EmacsWindow.java b/java/org/gnu/emacs/EmacsWindow.java index 5e45275631b..0e96a8382d0 100644 --- a/java/org/gnu/emacs/EmacsWindow.java +++ b/java/org/gnu/emacs/EmacsWindow.java @@ -1377,7 +1377,7 @@ else if (EmacsWindow.this.isMapped) if (tem != null) { - activity = (EmacsActivity) getAttachedConsumer (); + activity = (EmacsActivity) tem; activity.syncFullscreenWith (EmacsWindow.this); } }