love.graphics.newImage hanging

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.
User avatar
BOT-Brad
Citizen
Posts: 87
Joined: Tue Dec 02, 2014 2:17 pm
Location: England

love.graphics.newImage hanging

Post by BOT-Brad » Fri Feb 13, 2015 8:06 pm

I'm trying to load in images both from the .love file and also the Love save-directory, however when attempting to do this for my required purpose, the entire LOVE application hangs for anywhere from 1 to 5 seconds. When the application resumes (With the images now loaded in), all of my setup timers and tweens and events have all already fired and finished, and the dt values returned by love.update are super high.

Is there anyway to stop .newImage from hogging up the application, and at least show some sort of "Loading" message or something?
Follow me on GitHub! | Send me a friend request on PSN!

szensk
Party member
Posts: 155
Joined: Sat Jan 19, 2013 3:57 am

Re: love.graphics.newImage hanging

Post by szensk » Fri Feb 13, 2015 8:44 pm

Solution: Use a threaded image loader.

Question: how many/how big of images are you loading? 1-5s delay is quite long.

User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: love.graphics.newImage hanging

Post by bartbes » Fri Feb 13, 2015 8:51 pm

Honestly, I'm not too convinced of the benefits of a threaded loader for images, since the final loading stage still has to happen on the main thread. I'd advice you to only load a few images at a time, then drawing a frame with the loading screen or whatever, then load some more, draw the screen, repeat. There's two easy ways to implement this, the first is coroutines, and the second is having a table with image paths to load, then taking the first few elements every time.

User avatar
s-ol
Party member
Posts: 1077
Joined: Mon Sep 15, 2014 7:41 pm
Location: Cologne, Germany
Contact:

Re: love.graphics.newImage hanging

Post by s-ol » Sat Feb 14, 2015 2:02 am

bartbes wrote:Honestly, I'm not too convinced of the benefits of a threaded loader for images, since the final loading stage still has to happen on the main thread. I'd advice you to only load a few images at a time, then drawing a frame with the loading screen or whatever, then load some more, draw the screen, repeat. There's two easy ways to implement this, the first is coroutines, and the second is having a table with image paths to load, then taking the first few elements every time.
love-loader actually doesn't seem to be doing this, though I also thought that wasn't possible oO or maybe I just misread the source?

s-ol.nu /blog  -  p.s-ol.be /st8.lua  -  g.s-ol.be /gtglg /curcur

Code: Select all

print( type(love) )
if false then
  baby:hurt(me)
end

bizziboi
Citizen
Posts: 55
Joined: Sat Apr 16, 2011 9:24 am

Re: love.graphics.newImage hanging

Post by bizziboi » Sat Feb 14, 2015 5:14 am

If you load on the thread to a binary blob, and create an image of that on the mainthread (assuming Love is built with a not shared context) you'd still have the main bottleneck (disk I/O) off the main thread which would be a significant win?

User avatar
Jasoco
Inner party member
Posts: 3651
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: love.graphics.newImage hanging

Post by Jasoco » Sat Feb 14, 2015 6:05 pm

I too am curious as to how many images you're trying to load and how big they are. Because most projects won't ever take even a second to load all the resources. Can we see a .love file so we can understand your POV?

User avatar
BOT-Brad
Citizen
Posts: 87
Joined: Tue Dec 02, 2014 2:17 pm
Location: England

Re: love.graphics.newImage hanging

Post by BOT-Brad » Sun Feb 15, 2015 9:44 am

I am currently loading around 4 images that are about 1300x700 pixels and then around 30 that are 48x48 and 30 that are 128x128.

Ill post up a love shortly when I'm on desktop pc.
Follow me on GitHub! | Send me a friend request on PSN!

User avatar
riidom
Citizen
Posts: 74
Joined: Wed Jun 19, 2013 4:28 pm
Location: irgendwo an der Elbe
Contact:

Re: love.graphics.newImage hanging

Post by riidom » Sun Feb 15, 2015 10:33 am

Ok, a few thoughts beforehand:

First, if you group the tiles to sheets, loading few big files should go smoother than loading many small ones.

Second, have you been on a laptop so far? Maybe one with a slow hard disc? I have one of these myself, and it suffers a lot from loading hiccups; I had to move some games and software to my fast but small SSD because it was so annoying. So maybe the problem wont appear on your desktop at all.

User avatar
Jasoco
Inner party member
Posts: 3651
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: love.graphics.newImage hanging

Post by Jasoco » Sun Feb 15, 2015 4:24 pm

Yeah, please upload a .love. Even if it's just the images and loading code. I'm curious to see how fast it loads on my machines to get a benchmark. (I always prefer to break images into small pieces, if they're bigger than 1024x1024 or even 512x512. But don't know if that would make a difference.)

Also, could it be that since your large 1300x700 images aren't PO2 sized, maybe Löve is taking a long time to pad them? Those images, on a system that doesn't support PO2, but does support padding them, will be resized to 2048x1024 and I could see that being a pretty big bottleneck. (Providing the padding even adds time to loading. I don't know as I never had a machine that didn't support PO2.)

Try this, try timing how long it takes to do each image size group. Especially the large ones.

User avatar
BOT-Brad
Citizen
Posts: 87
Joined: Tue Dec 02, 2014 2:17 pm
Location: England

Re: love.graphics.newImage hanging

Post by BOT-Brad » Sun Feb 15, 2015 10:13 pm

Here is a very quick demo I threw together. On my machine (Windows 7, 64-bit, Intel i3-2120 @ 3.3GHz, AMD Radeon 7860 GPU, 16GB RAM) this demo ALWAYS takes at least 5 seconds to load and then start producing its epileptic-fit inducing drawing cycle.
Attachments
ImageLoadTest.love
(5.1 MiB) Downloaded 44 times
Follow me on GitHub! | Send me a friend request on PSN!

Post Reply

Who is online

Users browsing this forum: No registered users and 15 guests