android
Prev Previous Post   Next Post Next
  #1  
Old 04-16-2010, 08:16 AM
Brett_val's Avatar
Brett_val Brett_val is offline
Senior Member
 
Join Date: Jan 2010
Location: The Netherlands
Posts: 636
Default Idle shutdown freezing - investigation thread

After Zaffo found that iago1460's event-test tool contradicts my findings, I have to reject my conclusion and change this thread into an investigation thread.

"Findings" section - contains information that is found to be working.
"Testings" section - contains current investigations and questions.

Findings at idle shutdown

1
Code without control.isButton() freezes.
Code:
screen.fillrect(0,0,400,240,color.new(0,0,0))
text.color(color.new(255,255,255))
ts=16
text.size(ts)

while true do 
	screen.fillrect(100,100,200,20,color.new(0,0,0))
	text.draw(100,100,tostring(os.date()))
	screen.update()
	if control.read()==1 then
		if control.isTouch()==1 then
			if touch.click()==1 then
				break
			end
		end
	else
	os.wait(50)
	end

end
2
Code with button.click()==1 then break closes properly on idle shutdown.
Code:
screen.fillrect(0,0,400,240,color.new(0,0,0))
text.color(color.new(255,255,255))
ts=16
text.size(ts)

while true do 
	screen.fillrect(100,100,200,20,color.new(0,0,0))
	text.draw(100,100,tostring(os.date()))
	screen.update()
	if control.read()==1 then
		if control.isButton()==1 then
			if button.click()==1 then
				break
			end
		end
	else
	os.wait(50)
	end

end
3
When button.click results in another loop, app is also closed properly.
(see post #5)

4
iago1460's Tool does shut down properly without having a break under if button.click()==1.
I played around with this information under Testings.

Testings

After putting an os.wait(500) in the loop, iago1460's tool allowed me to read the event on the screen when the player does idle shutdown:
Code:
button event:0:[home]:[click]
My interpretation of this is that the app received button.click, without button.up or button.down, because the count was still 0 (= first event)
After that the app closes properly. While a button.click does nothing to this app besides text.drawing the event that has happened, somehow the app did close.
Thoughts:
1 perhaps a control.isButton() is needed (long shot.. just to rule this out)
2 perhaps the player also breaks the active loop.
3 perhaps the player unloads the app as a whole, but somehow couldn't do this without freezing at the other scripts.
thought 1:
testscript Findings 1 now contains a useless button.click:

Code:
screen.fillrect(0,0,400,240,color.new(0,0,0))
text.color(color.new(255,255,255))
ts=16
text.size(ts)

while true do 
	screen.fillrect(100,100,200,20,color.new(0,0,0))
	text.draw(100,100,tostring(os.date()))
	screen.update()
	if control.read()==1 then
		if control.isTouch()==1 then
			if touch.click()==1 then
				break
			end
		elseif control.isButton()==1 then
			if button.click()==1 then
				text.draw(0,0,"buttonclick")
				screen.update()
			end
		end
	else
	os.wait(50)
	end

end
Result:
"buttonclick" shows on screen
doesn't go back to app menu
player freezes.

I think I can rule out thought 1.
New thoughts:
1 else os.wait() causes problems
To resemble the event-test tool, test script from findings 1 now contains control.read(1)==1, and therefore I can remove the else os.wait(50)
Code:
screen.fillrect(0,0,400,240,color.new(0,0,0))
text.color(color.new(255,255,255))
ts=16
text.size(ts)

while true do 
	screen.fillrect(100,100,200,20,color.new(0,0,0))
	text.draw(100,100,tostring(os.date()))
	screen.update()
	if control.read(1)==1 then
		if control.isTouch()==1 then
			if touch.click()==1 then
				break
			end
		end
	end
end
Result:
Doesn't go back to app menu.
Player shuts down properly.


Black Jack:
added: control.read(1)==1
Code:
while (1) do
	for i = 0, 10 do
		if (control.read(1)==1) then
			if (control.isTouch()==1) then
				x,y = touch.pos()
				if (touch.click() == 1) then
					checkClick(x,y)
				elseif(touch.move() == 1) then
					checkMove(x,y)
				end
			elseif (control.isButton()==1) then
				if button.click() == 1 then
					ask = true	--Activate settings screen
					prompt = "Quit?"	--Set prompt message
					if (sound == true) then	--If not muted
						press:play()	--Play button sound
					end
				elseif (button.hold() ==1) then
					volume = true	--activate volume menu
					if (sound == true) then	--If not muted
						press:play()	--Play button sound
					end
				end
			end
		end
	end
	if (quit == true) then
		os.wait(500)
		break
	end
	drawScreen()
	os.sleep(1)
end
Result:
(I cripped the game doing this, it now only responds after a few clicks, and then it has skipped a few steps. I'm not sure why actually.. it seems like control.read(1) forces the loop to wait until there is an input?)

"Quit?" prompt didn't appear
doesn't go back to app menu
player shuts down properly
Thoughts:

1 perhaps the absence of os.wait allowed the player to shut down properly?
Conclusions

-idle shutdown sends a buttonclick to the app
-


Solutions

1 (more of a workaround)
Code to shutdown the app after 4 minutes (to prevent the app from having to idle shutdown and cause problems)
Code:
starttime=os.time()
while true do 
	if control.read()==1 then
		starttime=os.time()
	else
		if os.time()-starttime>240 then --checks is it was more than 240 seconds ago since the last control.read input.
			break 
		end
	end
end
But if you're using the accelerometer, then control.read() will always be 1 so then you'd have to put these lines under if control.isTouch()==1 else

Notes

Hopefully this will get sorted out so I can post something that will work in any case.

Last edited by Brett_val; 04-19-2010 at 01:54 PM.
Reply With Quote

Advertisement [Remove Advertisement]

 

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT -5. The time now is 09:31 AM.