newCanvas causing hard freeze

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
kexisse
Citizen
Posts: 56
Joined: Wed Jun 13, 2012 2:52 pm

newCanvas causing hard freeze

Post by kexisse »

Yes it's another Canvas-related thread.

I made a mistake in my code and called newCanvas with values of around 7000. It causes my machine (mac air) to freeze, requiring a hard reboot.
I've fixed the bug, but in the future I can see this happening as I make larger levels. It also made me wonder about newCanvas in general.

I have a few questions:
  • What sort of ranges are "acceptable" for newCanvas
  • Do other people get similar problems when calling newCanvas with such a large number?
  • If this is a known issue, can we get Löve to throw a normal Lua error instead of crashing the entire machine? Or implement some kind of safeguards that could be overridden in conf.lua
User avatar
Jasoco
Inner party member
Posts: 3725
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: newCanvas causing hard freeze

Post by Jasoco »

Don't go so high. I do not recommend making a canvas, or using an image, over 1024x1024 at most per image or canvas. 2048x2048 at most. It depends on the video card and a lot don't support even past 1024.

On my Air I've had 4096 pixel canvases load, but it takes a few seconds and you can't have too many before memory runs out. I'd recommend keeping it small. If you need something huge, break it up into multiple canvases or images to make it easy and prevent problems on other peoples lesser machines.

See, video cards vary. Some are really good and some really bad. It's all in the drivers. And some drivers just suck ass. I've never had problems on any of my Macs, but a lot of people here will talk about how much they hate their lack of canvas support.

I believe when Löve creates a canvas, it has to set aside the proper bits for every pixel in its size using a sort of nested for loop and the bigger the canvas to create, the longer it takes to create it. And if you create one too big, you eventually run out of memory, but before that, your computer will slow to a crawl while Löve sucks up every free bit in memory to use for your ginormous canvas. I assume someone here could tell you how many bits each pixel would take up.

I've done a lot of experimenting with large tables and giant canvases. The larger you go, the longer it takes to create, the more memory it takes up.
Post Reply

Who is online

Users browsing this forum: No registered users and 15 guests