I am writing a game for android and I use the Canvas.drawBitmap() to draw all the images of the game. For some reason the method has sudden spikes in performance. Here is a log i printed out which measures the speed of drawing for the exact same bitmap:
11-06 18:26:11.288: I/System.out(30762): time to draw bitmap: 3ms
11-06 18:26:11.308: I/System.out(30762): time to draw bitmap: 4ms
11-06 18:26:11.343: I/System.out(30762): time to draw bitmap: 2ms
11-06 18:26:11.353: I/System.out(30762): time to draw bitmap: 3ms
11-06 18:26:11.388: I/System.out(30762): time to draw bitmap: 2ms
11-06 18:26:11.403: I/System.out(30762): time to draw bitmap: 3ms
11-06 18:26:11.458: I/System.out(30762): time to draw bitmap: 14ms !!!
11-06 18:26:11.483: I/System.out(30762): time to draw bitmap: 15ms !!!
11-06 18:26:11.493: I/System.out(30762): time to draw bitmap: 2ms
11-06 18:26:11.508: I/System.out(30762): time to draw bitmap: 3ms
11-06 18:26:11.533: I/System.out(30762): time to draw bitmap: 2ms
11-06 18:26:11.553: I/System.out(30762): time to draw bitmap: 2ms
11-06 18:26:11.568: I/System.out(30762): time to draw bitmap: 1ms
11-06 18:26:11.593: I/System.out(30762): time to draw bitmap: 6ms !!!
11-06 18:26:11.623: I/System.out(30762): time to draw bitmap: 7ms !!!
11-06 18:26:11.638: I/System.out(30762): time to draw bitmap: 2ms
11-06 18:26:11.653: I/System.out(30762): time to draw bitmap: 2ms
11-06 18:26:11.668: I/System.out(30762): time to draw bitmap: 1ms
11-06 18:26:11.683: I/System.out(30762): time to draw bitmap: 1ms
11-06 18:26:11.703: I/System.out(30762): time to draw bitmap: 2ms
And so it continues. When drawing one image it doesn't affect the game but when we are talking about a larger amount of images the fps drops significantly.
What is funny (in both terms of the word) is that when I run the app in debug mode the drawing time stays consistent and low (1 - 2 ms), so I know that the method is capable of working properly. I would really(!) appreciate help here... I've been trying to find the reason for this for 3 days now.
EDIT
Just tested the app on other devices and seems like the only problematic device is the Samsung Galaxy s5.