Chris W
Chris W

Reputation: 805

Logs and performance, Android (SurfaceView)

I've created a game and every tick of the game loop this log occurs

09-05 07:53:20.213 27150-27240/com.x.y I/SurfaceView: Locking canvas... stopped=false, win=android.view.SurfaceView$MyWindow@32beabb4 09-05 07:53:20.226 27150-27240/com.x.y I/SurfaceView: Returned canvas: android.view.Surface$CompatibleCanvas@34b823dd

How to prevent this log from occurring? I'm worried it is affecting performance.

Upvotes: 5

Views: 1038

Answers (1)

Joanna Kotuła
Joanna Kotuła

Reputation: 169

Solution

The only solution I have found so far is an ugly hack:

private void disableSurfaceViewLogging() {
    try {
        Field field = SurfaceView.class.getDeclaredField("DEBUG");
        field.setAccessible(true);
        field.set(null, false);
        Log.i(TAG, "SurfaceView debug disabled");
    } catch (Exception e) {
        Log.e(TAG, "while trying to disable debug in SurfaceView", e);
    }
}

Explanation

SurfaceView has a constant DEBUG which switches the logging. Somehow it is true (when you look at the code you'll see that it should be false). I couldn't find any other, more "proper" way around.

I relied on the following answers:

Upvotes: 1

Related Questions