Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

[RESOLVED] Graphics 2.0 - Bad Performance (Image Loading)
Started by XWL Nov 15 2013 04:05 PM

39 replies to this topic
graphics 2.0 2.0 lag slow choppy freeze
[TOPIC CONTROLS]
Page 2 of 2 1 2
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#26

walter

[GLOBAL: userInfoPane.html]
walter
  • Moderator

  • 726 posts
  • Alumni

@rakoonic, as mentioned above, we're working on a new API that will allow you to control this, so you get to control the pre-load.



[TOPIC: post.html]
#27

spideri

[GLOBAL: userInfoPane.html]
spideri
  • Contributor

  • 106 posts
  • Corona SDK

As requested. On my iPad 3 I see no noticeable performance difference between G1 and G2 (with lots of particles).

 

G1: https://www.dropbox.com/s/h6l6i9ncrs340ft/Photo%2021-11-2013%2010%2006%2047.png

G2: https://www.dropbox.com/s/69a9zyq5910mmzr/Photo%2021-11-2013%2010%2015%2057.png

 

They both start thrashing the same once a certain number of particles is reached. Great that G2 uses less video memory though.

 

@Walter Can we get that 5000 fish sample please?



[TOPIC: post.html]
#28

rakoonic2

[GLOBAL: userInfoPane.html]
rakoonic2
  • Contributor

  • 503 posts
  • Corona SDK

Apologies, Walter, I missed that bit.



[TOPIC: post.html]
#29

Bryan01

[GLOBAL: userInfoPane.html]
Bryan01
  • Enthusiast

  • 95 posts
  • Corona Staff

Thanks for all of the feedback. In the upcoming daily build, we have changed the default behavior to load textures at the time of the newImage call.

 

To opt-out of this and lazy load the image, we added a new option: display.setDefault( "preloadTextures", false )



[TOPIC: post.html]
#30

ksan

[GLOBAL: userInfoPane.html]
ksan
  • Corona Geek

  • 2,795 posts
  • Corona SDK

Super! This sounds like a best fit solution for all. Thank you very much.



[TOPIC: post.html]
#31

alan_slane

[GLOBAL: userInfoPane.html]
alan_slane
  • Observer

  • 13 posts
  • Corona SDK

OK. That explains why I was getting these temporary hangs after implementing G2.0 every time I started an app.

 

I didn't want to modify all the image loading in every module within my apps, so to solve this problem (I hope temporarily) I created a small module with overridden functions that force a load.

--
-- override.lua
--

local saved = {};

saved.newImage = display.newImage;

display.newImage = function(...)
	local forceLoad = saved.newImage(select(1, ...));
	forceLoad.width, forceLoad.height = 0.1, 0.1;
	timer.performWithDelay(100, function() forceLoad:removeSelf(); end);
	
	local img = saved.newImage(select(1, ...));
	return img;
end


saved.newImageRect = display.newImageRect;

display.newImageRect = function(...)
	local forceLoad = saved.newImageRect(select(1, ...));
	forceLoad.width, forceLoad.height = 0.1, 0.1;
	timer.performWithDelay(100, function() forceLoad:removeSelf(); end);
	
	local img = saved.newImageRect(select(1, ...));
	return img;
end

 

The only thing that needs to done after this is to put require("override") at the top of main.lua.

I tested this on some projects and it seems to work well. The initial lag I saw was gone.

 

It's not pretty, but it's functional...

 

To take Bryan's sample app it would become:

-- 
-- main.lua
--

require("override")

local imageToLoad = "boxer-1920.jpg"

local background = display.newImage( imageToLoad, display.contentCenterX, display.contentCenterY )
background.alpha = 0 -- Without the "override" step the image in background isn't loaded until it becomes visible

local myText = display.newText( "Moving text!", 0,0, native.systemFont, 40 )
myText:setFillColor( 1, 255/255, 255/255 )

transition.to( myText, { time=10000, x=320, y=480 } )

local function test()
	background.alpha = 1
	background.x = 0
end

timer.performWithDelay( 5000,  test)

This works great! Thank you! :)



[TOPIC: post.html]
#32

ingemar

[GLOBAL: userInfoPane.html]
ingemar
  • Corona Geek

  • 2,733 posts
  • Enterprise

This isn't be needed anymore as of build 2087:

 

Release notes for build 2013. through 2013.2087

Core: Adding new option to display defaults to preloadTextures via display.setDefault( "preloadTextures", true/false ) (default is true to function like graphics 1.0)



[TOPIC: post.html]
#33

marcior

[GLOBAL: userInfoPane.html]
marcior
  • Enthusiast

  • 60 posts
  • Corona SDK

If I use storyboard.loadScene(), do I also have to set the flag?

Put it another way, does the storyboard.loadScene() count as loading images with alpha=0 for the new engine??



[TOPIC: post.html]
#34

jacques1

[GLOBAL: userInfoPane.html]
jacques1
  • Contributor

  • 314 posts
  • Corona SDK

what did happen to the promised 5000 fish on screen at a time? I spent a lot of time migrating my game to 2.0 as I had numerous sprites onscreen at the same time so 2.0 sounded great. But now, well, to see no improvement in performance and on occasion even perform worse then 1.0 is a huge disappointment. Also, what happened to daily builds? The last one 2100 is from way back in dec 7.



[TOPIC: post.html]
#35

nglenister

[GLOBAL: userInfoPane.html]
nglenister
  • Enthusiast

  • 38 posts
  • Corona SDK

Is there an update on the Graphics 2.0 performance issues. I too have updated my game only to see a huge reduction in fps (especially on console platforms like GameStick). It looks like I will have to go back to Graphics 1.0 unless this is going to be fixed soon?



[TOPIC: post.html]
#36

Matthew Pringle

[GLOBAL: userInfoPane.html]
Matthew Pringle
  • Contributor

  • 660 posts
  • Corona SDK

Is there an update on the Graphics 2.0 performance issues. I too have updated my game only to see a huge reduction in fps (especially on console platforms like GameStick). It looks like I will have to go back to Graphics 1.0 unless this is going to be fixed soon?

 

What issues are you having exactly?



[TOPIC: post.html]
#37

nglenister

[GLOBAL: userInfoPane.html]
nglenister
  • Enthusiast

  • 38 posts
  • Corona SDK

What issues are you having exactly?


Hi Matthew,

Same problems as others in this topic, the performance seems to have taken a drastic hit since graphics 2.0 was released? I'm now getting max 30-40 fps on gamestick rendering my game nearly unplayable compared to 50fps prior to graphics 2.0.

[TOPIC: post.html]
#38

nglenister

[GLOBAL: userInfoPane.html]
nglenister
  • Enthusiast

  • 38 posts
  • Corona SDK

What issues are you having exactly?


Hi Matthew,

Same problems as others in this topic, the performance seems to have taken a drastic hit since graphics 2.0 was released? I'm now getting max 30-40 fps on gamestick rendering my game nearly unplayable compared to 50fps prior to graphics 2.0.

[TOPIC: post.html]
#39

nglenister

[GLOBAL: userInfoPane.html]
nglenister
  • Enthusiast

  • 38 posts
  • Corona SDK

Sorry for the double post, was using my mobile :/.



[TOPIC: post.html]
#40

Matthew Pringle

[GLOBAL: userInfoPane.html]
Matthew Pringle
  • Contributor

  • 660 posts
  • Corona SDK

Hi nglenister

 

Have you looked into the preloading issues that were causing some fps drops?

 

The reason is that programming directly into graphics 2.0, I'm able to shift and transform around a hundred of polygons without any performance drop at all. Used to make a 3D engine.

 

Can you strip out a lot of the game code and replicate the issue?

 

Matt




[topic_controls]
Page 2 of 2 1 2
 
[/topic_controls]