Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
Game runs fine in simulator, very very slowly on device (iPhone 6 Plus running 9.3) — Gideros Forum

Game runs fine in simulator, very very slowly on device (iPhone 6 Plus running 9.3)

AstirianAstirian Member
edited February 2017 in Bugs and issues
Hi guys,

Pretty much what the title says. I've run it through Xcode via USB and also from the Gideros Player targeting the phone over Wi-Fi but it's very, very slow. Will try on Android next and update the thread. It's a simple 2D endless runner so wouldn't have thought it too taxing.

Oh, I almost forgot, I added: print ("memory used 1:"..collectgarbage("count"))

I don't seem to have any leaks. Using between 500 and 700... uh, MB?

Comments

  • Oh dear, it's slow in the Android Studio simulator too, although I guess that could be a good thing.
  • hgy29hgy29 Maintainer
    500-700MB is quite a lot for a phone, no doubt! Are you using very large textures, or trying to put all your game on stage at once and just scrolling it ?
    It is hard to tell why it can be slow without knowing how you manage your assets. Can you tell us more ?
  • Sorry that was kb. I'm going to try the suggestions here: http://giderosmobile.com/forum/discussion/comment/8857#Comment_8857

    I'm using SceneManager and separate *.lua files for scenery animation etc... You raise a good point though, I don't have any loading classes but my textures aren't really that big. Though I do need to learn how to do loading screens at some point. :D
  • hgy29hgy29 Maintainer
    Oh ok, if this was kb, then it is really nothing even for a phone. It remains that desktop CPU are far more efficient than phone ones, so you may be CPU bound. Could it be that your lua code is CPU intensive, or you are using lots of enter_frame events ?
  • AstirianAstirian Member
    edited February 2017
    I can see the game welcome scene and options scene is a bit slow too. There's a fair number of things going on in my main game enter_frame:
    function GameScene:onEnterFrame(e)
     
    	local dt = e.deltaTime
     
    	local player = PLAYER
    	player:update(dt)
     
    	if (gameStarted == 1) then
     
    		Scenery:updateBackgrounds()
    		Blocks:updateBlocks()
    		GameScene:updateObstacles()
    		GameScene:updateCoins()
    		GameScene:updateScore()
     
    		if (firstObstaclesAvoided == true) then
     
    			clear(obstacles) -- Removes all sprite children.
    			obstacles = nil
     
    			table.remove(ALL_OBSTACLES, 1)
    			table.remove(ALL_OBSTACLES, 1)
    			table.remove(ALL_OBSTACLES, 1)
     
    			firstObstaclesAvoided = false
    			GAME:addObstacles()
    			-- print("Adding ONE again...")
    		end
     
    		if (secondObstaclesAvoided == true) then
     
    			clear(secondObstacles) -- Removes all sprite children.
    			secondObstacles = nil
     
    			table.remove(ALL_OBSTACLES, 1)
    			table.remove(ALL_OBSTACLES, 1)
    			table.remove(ALL_OBSTACLES, 1)
     
    			secondObstaclesAvoided = false
    		end
     
    		if (LIVES == 0) then
     
    			-- Is the below really needed?
    			OBSTACLES = nil
    			ALL_OBSTACLES = nil
    			player = nil
    			GameScene:gameOver()
    		end	
    	end
     
    	if self.touchStart then
    		if os.timer()*1000 - self.touchStart >= self.timeLimit*2/3 then
    			 self.touchCount = 0
    			 self:check()
    			 self:C()
    		end
    	end
     
    	if self.timeStarted then
    		if os.timer()*1000 - self.timeStarted >= self.timeLimit then
    			  self:check()
    	end
       end
    end
  • You could pm it to someone here who could export and test it to see if something is going wrong somewhere.
    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
  • That'd be awesome yeah, if someone's willing to take a look I can upload to Dropbox. :) I'm sure there are a good many things I've done weird.
  • hgy29hgy29 Maintainer
    @SinisterSoft, I am sure you are the best person here on the forum to help @Astirian with lua/optimizations techniques.
  • antixantix Member
    edited February 2017
    It looks like part of your problem might be that you are using a lot of global variables.

    You are also calling functions like GameScene:updateScore() from inside the GameScene class. Those calls should be like self:updateScore()

    When you create global tables and stuff like ALL_OBJECTS you should make references to them either in the class (self.allObstacles = ALL_OBSTACLES), or create local references to them when you are going to access them. You did this in the first few lines with local player = PLAYER which IMHO is the way to do it, or at least that's how I do it heheh

    Look at your different variables and see what might be better suited elsewhere. An example is LIVES. This would most likely be better as a variable inside the player class (player.lives)

    I hope I have been of some help :ar!
  • Thanks antix :), I have indeed been a bit schizophrenic with my variables, I'll tidy them up. I've also noticed my co-ords are a bit messed up on the devices, the player can jump 3x too high but that's probably for another post.
  • AstirianAstirian Member
    edited February 2017
    So, if I'm using SceneManager, it doesn't really know about the code in my GameScene if the app has just loaded and I'm still in WelcomeScene right?

    The reason I ask is that the transition between my bare bones WelcomeScene and AboutScene is a little laggy too. Perhaps I have something in my main.lua or config.lua that's causing issues as well.

    Maybe I'm also doing some weird scaling thing too with the resolution... My player character's jump looks like it has tripled on devices and the Xcode simulator. Could be my resolution settings/project settings are out of whack and everything's getting redrawn?

    Stuff like this is probably trouble:

    In my WelcomeScene:
    	local icon = Bitmap.new(Texture.new("textures/temp_icon.png", true))
    	icon:setPosition(unpack(UI:place(icon, "topRight")))
    	self:addChild(icon)
    In my config.lua:
    function UI:place(node, zone)
     
            ...
     
    	-- Top Left
    	if (zone == "topLeft") then
    		zone = {-dx, -dy}
     
    	-- Top Center
    	elseif (zone == "topCenter") then
    		zone = {(application:getContentWidth()-node:getWidth())/2, -dy}
     
    	-- Top Right
    	elseif (zone == "topRight") then
    		zone = {dx + width-node:getWidth(), -dy}
     
    	else
    		print("UI Placement Error!")
    	end
     
    	return zone
    end
    Should I be nil-ing my vars on scene transition?
  • AstirianAstirian Member
    edited February 2017
    Call the press, I'm still a goomba!

    I had updated Gideros to the latest version and I just tried to revert to much earlier build of my game, which was on a different branch so I set up a new test project. When I went to project settings I added the name and set up the resolution etc...

    Anyway, I reverted back to the current build and noticed there was no name in the project settings and uhm... FPS set to 30... Changed it to 60 and the game is smooth as silk, on device, just as per the Gideros Player.

    /facepalm

    Learned a few things though, so thanks for your help guys. :D

    (and no weird co-ord issues with jumping either...)

    Likes: SinisterSoft

    +1 -1 (+1 / -0 )Share on Facebook
  • antixantix Member
    Accepted Answer
  • :D
    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
  • SinisterSoftSinisterSoft Maintainer
    edited February 2017
    btw, you want to check to see if the game looks ok if you force the game to 30hz in the player. I detect the slowdown in my games and have a multiplier for the problem.

    eg, x=x+(30*step) -- step being normally 1, but can be bigger/smaller if not 60hz.
    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
Sign In or Register to comment.