Page 1 of 1

Bug in Newest Android Version (June 14, 2019)

Posted: Mon Jun 17, 2019 3:01 am
by PEB
The following code worked fine on the previous version of the Hollywood Player for Android; but now it displays wrong and crashes after the screen is rotated. (The same problem also shows up in the newest APK Compiler, 3.1)

Code: Select all

@REQUIRE "RapaGUI"
@REQUIRE "polybios"
@DISPLAY {Title="Test", Color=#WHITE, Layers=True, Width=600, Height=1920, ScaleMode=#SCALEMODE_LAYER, SmoothScale=True, Hidden=True, SingleMenu=True}

DesiredWidth=600
DesiredHeight=1920

CreateBrush(1, 600, 1920, #BLUE)
SetLineWidth(50)
SelectBrush(1)
	Box(0, 0, 600, 1920, #RED)
	Box(#CENTER, #CENTER, 400, 400, #RED)
EndSelect
DisplayBrush(1, 0, 0)

AppGUI$=[[<application id="app">
	<window id="Main" notify="orientation">
		<vgroup frame="true">
			<hollywood id="HWDisplay" FixWidth="false" FixHeight="false" display="1"/>
		</vgroup>
	</window>
</application>]]
moai.CreateApp(AppGUI$)

Function p_RapaGUIEvents(msg)
	Switch msg.attribute
	Case "Orientation":
		If moai.get("Main", "Orientation")="Portrait"
			Local ScreenHeight=moai.get("Main", "Height")*2-DisplayScreenDiff
			SetDisplayAttributes({ScaleWidth=100*(ScreenHeight/DesiredHeight) .. "%", ScaleHeight=100*(ScreenHeight/DesiredHeight) .. "%"})
		ElseIf moai.get("Main", "Orientation")="Landscape"
			Local ScreenHeight=moai.get("Main", "Height")*2-DisplayScreenDiff
			SetDisplayAttributes({ScaleWidth=100*(ScreenHeight/DesiredHeight) .. "%", ScaleHeight=100*(ScreenHeight/DesiredHeight) .. "%"})
		EndIf
	EndSwitch
EndFunction
InstallEventHandler({RapaGUI=p_RapaGUIEvents})

Local TempVar=moai.get("Main", "Height")*2
Local ScreenHeight=GetAttribute(#DISPLAY, 1, #ATTRSCALEHEIGHT)
DisplayScreenDiff=TempVar-ScreenHeight
SetDisplayAttributes({ScaleWidth=100*(ScreenHeight/DesiredHeight) .. "%", ScaleHeight=100*(ScreenHeight/DesiredHeight) .. "%"})

Repeat
	WaitEvent
Forever

Re: Bug in Newest Android Version (June 14, 2019)

Posted: Fri Jun 21, 2019 12:28 pm
by airsoftsoftwair
Right, crashes here too but not only in the latest version (June 14) but also in all other versions of Hollywood Player 8.0 for Android. Are you sure that this worked in previous versions? I've tested all 4 versions of Hollywood Player 8.0 for Android and it crashes with all of them.

Re: Bug in Newest Android Version (June 14, 2019)

Posted: Fri Jun 21, 2019 1:52 pm
by PEB
That code is a simplified version of the code that I'm using in a much larger app.
The actual app was definitely working well on the version of the Hollywood Player before the June 14th version. (I worked on it and tested it almost every day.) But now the display is completely wrong and it crashes when the orientation changes. The sample code at the start of this thread exhibits the same behavior.

Re: Bug in Newest Android Version (June 14, 2019)

Posted: Sat Jun 22, 2019 11:19 pm
by airsoftsoftwair
Hmm, strange. I've sent you some APKs. Let me know what you find out.

Re: Bug in Newest Android Version (June 14, 2019)

Posted: Mon Jun 24, 2019 10:07 am
by Juan Carlos
I can see that instruction BeginRefresh() that in Amiga and Windows in theory works in the Hollywood Player of Android not.

Re: Bug in Newest Android Version (June 14, 2019)

Posted: Sun Dec 08, 2019 5:32 pm
by airsoftsoftwair
This was fixed on June 29th, 2019. There were bugs both in Hollywood and in the script. Here's a corrected version of the script:

Code: Select all

; you need to set ScaleHollywood to FALSE; otherwise RapaGUI 2.0 will automatically activate
; SYSTEMSCALE for your display which makes Hollywood behave differently and we don't want that
; because you handle scaling yourself
@REQUIRE "RapaGUI", {ScaleHollywood = False}
@DISPLAY {Title="Test", Color=#WHITE, Layers=True, Width=600, Height=1920, ScaleMode=#SCALEMODE_LAYER, SmoothScale=True, Hidden=True, SingleMenu=True}

DesiredWidth=600
DesiredHeight=1920

CreateBrush(1, 600, 1920, #BLUE)
SetLineWidth(50)
SelectBrush(1)
	Box(0, 0, 600, 1920, #RED)
	Box(#CENTER, #CENTER, 400, 400, #RED)
EndSelect
DisplayBrush(1, 0, 0)

AppGUI$=[[<application id="app">
	<window id="Main" notify="orientation">
		<vgroup frame="true">
			<hollywood id="HWDisplay" FixWidth="false" FixHeight="false" display="1"/>
		</vgroup>
	</window>
</application>]]
moai.CreateApp(AppGUI$)

Function p_RapaGUIEvents(msg)

	Switch msg.attribute
	Case "Orientation":
		If moai.get("Main", "Orientation")="Portrait"
			Local ScreenWidth, ScreenHeight

			; Android is very asynchronous in its nature and you can't expect Area.Height
			; to already contain the height of the new orientation at this time; so let's
			; poll until the orientation change is reflected in what we get from Area.Width/Height			
			Repeat
				ScreenWidth = moai.get("Main", "Width")
				ScreenHeight = moai.get("Main", "Height")
				VWait
			Until ScreenHeight>ScreenWidth
			
			ScreenHeight = ScreenHeight*2-DisplayScreenDiff	
			SetDisplayAttributes({ScaleWidth=100*(ScreenHeight/DesiredHeight) .. "%", ScaleHeight=100*(ScreenHeight/DesiredHeight) .. "%"})
		ElseIf moai.get("Main", "Orientation")="Landscape"
			Local ScreenWidth, ScreenHeight
			
			; see note above
			Repeat
				ScreenWidth = moai.get("Main", "Width")
				ScreenHeight = moai.get("Main", "Height")
				VWait
			Until ScreenWidth>ScreenHeight
			
			ScreenHeight = ScreenHeight*2-DisplayScreenDiff	
			SetDisplayAttributes({ScaleWidth=100*(ScreenHeight/DesiredHeight) .. "%", ScaleHeight=100*(ScreenHeight/DesiredHeight) .. "%"})
		EndIf
	EndSwitch

EndFunction
InstallEventHandler({RapaGUI=p_RapaGUIEvents})

; also note that multiplying by 2 will only be correct on devices which use
; a system scale factor of 2; you should multiply by the return value of
; #ATTRHOSTSCALE to be compatible with all devices
Local TempVar=moai.get("Main", "Height")*2
Local ScreenHeight=GetAttribute(#DISPLAY, 1, #ATTRSCALEHEIGHT)
DisplayScreenDiff=TempVar-ScreenHeight
SetDisplayAttributes({ScaleWidth=100*(ScreenHeight/DesiredHeight) .. "%", ScaleHeight=100*(ScreenHeight/DesiredHeight) .. "%"})

Repeat
	WaitEvent
Forever