Canvas saving and loading back only gets fuzzy for specific component sizes

I came across what seems like a bug when developing a undo/redo system for a drawing app. The idea is to save the canvas after each drawing action, and then restore the canvas by setting the canvas's background to the saved image when clicking undo.
After every drawing action, I save the canvas, clear the canvas and then set the canvas's background image to the last saved canvas.

What I noticed is that for specific canvas sizes, the background image gets fuzzier and fuzzier i.e. the old drawing actions start to get fuzzy with each save and load of the canvas. But for other canvas sizes the image stayed perfectly clear.

I created a small test case as follows:

  • Create new project
  • Add canvas to screen with width&height set to 300x300pixels, and cyan background (so that it is visible).
  • Add blocks to implement the save/load feature (as seen in the attached image)

  • Then you can test the app by tapping to draw circles, and you'll notice that with each successive tap, the older circles start to get fuzzy.
    e.g. below I tapped the top left circle first, then I tapped the bottom area a few times, and finally, I tapped the top right circle as a comparison:

e.g. Below I changed the canvas size to 300x250 (widthXheight) and did the same process as above, yet the circles stayed sharp. (smaller canvas sizes seem to work more reliably but I couldn't find any exact numbers as a transition point)

Setting the width/height to fill_parent also leads to fuzzy behaviour.
Below are some tests I did (numbers are widthXheight):

  • 250x300 lead to blurry results but 300x250 was clear.
  • 137(and higher)x300 lead to blurry results whereas 136(and lower)x300 was clear.

I didn't have time to do more tests, but there isn't a clear pattern as to what's causing it. I'm also not sure if it's dependent on the phone's screen resolution. I was testing on a Samsung A52 with 1080 x 2400 screen resolution.

Below is the project save file, if you want to test this bug.
CanvasTest.aia (1.8 KB)

Using chromebook and AI2 companion, tested all your "fuzzy" canvas dimensions, and had no issues with any of them.

This could possibly be a device specific thing?

Check on another device ...
Do you get the same result with Companion & APK?

With your code I get a new file in ASD/Pictures/ every time I generate a point.

I have modified this...

CanvasTest_2.aia (2.3 KB)

Notice how to save and get the file.

I have put strange dimensions but I have not been able to obtain fuzzy points, perhaps it is a matter of the density of the screen.

Android 9
Screen.DefaultFileScope: App

@Anke This bug appears both with the companion app and an apk.

@Juan_Antonio Thanks, although I decided for this small test case to keep it as simple as possible, to narrow down the cause.

After some further testing, I noticed that if I set my phone's screen zoom setting back to the lowest setting (as seen in this screenshot), then the issue disappears:

However, if I set it any larger (which is what I had previously), then it has the fuzziness effect.

I also tested on an LG G6, however, no matter what I set the display scaling setting to, I was always getting the fuzziness effect.

I was mistaken, changing the screen zoom only solved the issue for the specific canvas size I was testing with, but the issue still appears for some other canvas sizes :frowning_face: