5

I'm intermittently observing strange graphics artefacts in my app, as shown below. This is a screengrab from a Samsung Galaxy S3. I have only observed it on this particular phone. I have run the app on a Samsung Galaxy Tab S4 and an HTC One, and never observed this issue on either - although admittedly I do mainly use the S3 for development.

I considered that the issue might be some sort of concurrency clash in drawing to the Canvas (I'm using the basic Android rendering methods, no OpenGL or anything), since I can clearly recognise the repeating units of other UI elements, so I synchronized all the code which draws to or interacts with the Canvas and I'm still observing it happen.

It does clear itself up after around 30-90 seconds, which may be due to a regular scheduled memory cleanup operation it performs - so perhaps this is a manifestation of low available mem?

If I had enough rep I would stick a pretty big bounty on this. Any help appreciated. Hopefully someone recognises this particular problem.

Strange graphics artefacts

HomerPlata
  • 1,687
  • 5
  • 22
  • 39
  • Have you tried to perform drawing with hardware layer on [`View#setLayerType(View.LAYER_TYPE_HARDWARE, null)`](https://developer.android.com/reference/android/view/View.html#LAYER_TYPE_HARDWARE)? – azizbekian Apr 06 '17 at 07:52
  • Sorry for the late reply. I will give this a go. It may take a while to prove that the graphics errors no longer happen, but if it fixes things I will make sure to award the bounty to you. – HomerPlata Apr 10 '17 at 07:33
  • Will post as an answer. – azizbekian Apr 10 '17 at 07:34
  • I will increase the bounty on this when it expires later today. – HomerPlata Apr 12 '17 at 10:25

1 Answers1

2

Apply hardware layers:

setLayerType(View.LAYER_TYPE_HARDWARE, null);
azizbekian
  • 60,783
  • 13
  • 169
  • 249
  • Hi Aziz, I'm still getting the occasional graphics issues with your suggested fix - although I think it has made the display look a bit nicer, so I'll still vote up your answer at least. Thanks. – HomerPlata Apr 11 '17 at 23:13
  • I've awarded the bounty, since I only just realised that it would have vanished into the ether if I didn't, but I'm still in search of an answer. – HomerPlata Apr 13 '17 at 07:34