Total canvas memory use exceeds the maximum limit - iOS 15 beta with Safari

With the latest iOS 15 beta releases we have started seeing issues with memory and canvases. This error is not reproduced in any of the earlier iOS versions (with any devices), it is only present in the new iOS 15 beta versions.

The warning about total canvas memory is always followed with a javascript exception trying to do rendering on the canvas:

This is an history of it working in a iPhone 12 pro max with iOS 14.7.1.

This is history of it not working with an iPhone 11 with iOS 15 beta 5 (confirmed with beta 4 as well)

There are a couple of observations we've made:

  • It seems it is more easily reproduced by repeatedly triggering the new url bar and rotating the device a lot.
  • Clearing History and Website Data can fix the issue temporarily
  • When it is reproduced it can easily be reproduced again, even when reloading the page.

So it seems we've found the solution to our problem.

What caused the issue in iOS 15 was that we created a object list with canvas elements as properties and store them to a local variable and later assigned it to the this context.

To explain we had a method, let's call it createAnimationList, which created and returned a list of objects which in turned contained a canvas element (deeper down in properties).

var animationList = createAnimationList();

These items would after that be rendered to the canvas scene. Where the error happened was that we after that assigned it to the this context of the object which called the method from the beginning.

var animationList = createAnimationList();

addToCanvasScene(animationList);

this.animationList = animationList;

Next time this code was called the list created temporarily in animationList variable was kept in memory. What we did to fix this was add defensive coding to make sure createAnimationList wasn't called again. This might seem obvious looking at this simple example (the truth is a more complex obviously).

Something to think about is that our canvas elements was cache handled before with canvas.context.clearRect(0, 0, width, height), canvas.context.setTransform(1, 0, 0, 1, 0, 0), and more. This cache clearing works for us in all versions earlier than iOS 15

Hi @evolutiongaming this seems to be issue even in newest betas, did your solution still works?

Related topics:

https://developer.apple.com/forums/thread/684843

https://developer.apple.com/forums/thread/689071

9 months later, and still a problem. Can't seem to resolve it unless I restart Safari.

Total canvas memory use exceeds the maximum limit - iOS 15 beta with Safari
 
 
Q