0

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?

Dmitry
  • 2,837
  • 1
  • 30
  • 48
  • I wouldn't really focus on Android 2.3.6 anymore. It only accounts for around 6% of all Android devices:https://developer.android.com/about/dashboards/index.html. – Jared Burrows May 10 '15 at 22:56
  • For my app statistics is a bit different. I still have 24% of users on 2.3.6. However, not sure how many of them have Nexus S. – Dmitry May 10 '15 at 22:58
  • Alright, I was just giving you a heads up incase this was newer project. – Jared Burrows May 10 '15 at 23:03

1 Answers1

0

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); }

Dmitry
  • 2,837
  • 1
  • 30
  • 48
  • 1
    The output of `adb shell dumpsys SurfaceFlinger` is often helpful in these situations. The graphics arch doc goes through an example with the hardware composer summary -- https://source.android.com/devices/graphics/architecture.html#composition – fadden May 11 '15 at 15:42