Bug in Newest Android Version (June 14, 2019)

Report any Hollywood bugs here
Post Reply
PEB
Posts: 567
Joined: Sun Feb 21, 2010 1:28 am

Bug in Newest Android Version (June 14, 2019)

Post 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
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

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

Post 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.
PEB
Posts: 567
Joined: Sun Feb 21, 2010 1:28 am

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

Post 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.
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

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

Post by airsoftsoftwair »

Hmm, strange. I've sent you some APKs. Let me know what you find out.
User avatar
Juan Carlos
Posts: 887
Joined: Mon Sep 06, 2010 1:02 pm

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

Post by Juan Carlos »

I can see that instruction BeginRefresh() that in Amiga and Windows in theory works in the Hollywood Player of Android not.
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

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

Post 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
Post Reply