androidandroid-ndksurfaceviewsurfaceholdernexus-s

SurfaceView on Android 2.3.6 doesn't render full region


In my app I create SurfaceView and use it from NDK using ANativeWindow API: ANativeWindow_lock and then ANativeWindow_unlockAndPost.

The size of the surface is set by ANativeWindow_setBuffersGeometry to 320x480. The screen size is bigger - 480x800.

The SurfaceView is stretched using LayoutParams to almost full screen.

The problem that I see is that my frames are refreshed only in the region of 320x480.

screenshot

The other part of the surface is refreshed only if there is another view being animated on top or if I explicitly call postInvalidate on the surface view. However, postInvalidate works with delay.

This happens only on Nexus S with 2.3.6 with ROM from https://developers.google.com/android/nexus/images (2.3.6 (GRK39F)). The same device with 4.0.4 doesn't have this bug.

Works fine on Samsung Ace-2 with 2.3.6. Also works perfectly on higher versions of android.

Has anyone seen such bug? Pretty sure it is a bug on that particular phone. Any suggestions how to work around this?


Solution

  • After a bit of debugging and reading source code of SurfaceView I found solution. Apparently, ANativeWindow_setBuffersGeometry is not enough and the size should be also set from java. This helped me:

    public void surfaceCreated(SurfaceHolder holder) { holder.setFixedSize(BuildConfig.VIDEO_WIDTH, BuildConfig.VIDEO_HEIGHT); }