Page 1 of 1

RaiseOnError() with RapaGUI on Latest Android Player

Posted: Sun Apr 18, 2021 1:48 am
by PEB
Here's the code that shows the error:

Code: Select all

@REQUIRE "RapaGUI"

Function p_ErrorHandler(ErrCode, ErrStr$, ErrCmd, ErrLine)
	SystemRequest("Debug Output", "Code: "..ErrCode.."\nString: "..ErrStr$.."\nCommand: "..ErrCmd.."\nLine: "..ErrLine, "OK")
EndFunction

RaiseOnError(p_ErrorHandler)

Repeat
	WaitEvent
Forever
This is the error message that shows up:
Attempt to yield across metamethod/C-call boundary!
There also seems to be another error message behind it, but it disappears so fast that I can't read it.

Re: RaiseOnError() with RapaGUI on Latest Android Player

Posted: Mon Apr 19, 2021 4:55 pm
by amyren
The message behind is:

Debug Output
Code: 1635
String: This error is for internal use only.
Command: WaitEvent
Line: 10

Re: RaiseOnError() with RapaGUI on Latest Android Player

Posted: Sat Apr 24, 2021 2:44 pm
by airsoftsoftwair
Yes, this looks like a bug. Will be fixed.

Re: RaiseOnError() with RapaGUI on Latest Android Player

Posted: Thu Jun 24, 2021 9:13 pm
by airsoftsoftwair
Fixed now.

Re: RaiseOnError() with RapaGUI on Latest Android Player

Posted: Thu Jul 22, 2021 6:29 am
by PEB
This error is still showing up with the latest Android Player.

Code: Select all

@REQUIRE "RapaGUI"

Function p_ErrorHandler(ErrCode, ErrStr$, ErrCmd, ErrLine)
	SystemRequest("Debug Output", "Code: "..ErrCode.."\nString: "..ErrStr$.."\nCommand: "..ErrCmd.."\nLine: "..ErrLine, "OK")
EndFunction

RaiseOnError(p_ErrorHandler)

LoadBrush(1, "DoesNotExist")

Repeat
	WaitEvent
Forever

Re: RaiseOnError() with RapaGUI on Latest Android Player

Posted: Sat Jul 24, 2021 8:38 pm
by airsoftsoftwair
Hmm, the problem here is calling SystemRequest() in the error function. Functions that start a modal loop currently can't be used in the error function called by RaiseOnError() if RapaGUI is active. I'm not sure if this is easily fixable but I'll check.

Re: RaiseOnError() with RapaGUI on Latest Android Player

Posted: Sun Jul 25, 2021 7:09 am
by PEB
If it's a hard one to fix, this might be a good enough work-around:

Code: Select all

@REQUIRE "RapaGUI"

Function p_CustomErrorMessage(msg)
	SystemRequest("Debug Output", "Code: "..msg.userdata[0].."\nString: "..msg.userdata[1].."\nCommand: "..msg.userdata[2].."\nLine: "..msg.userdata[3], "OK")
EndFunction

Function p_ErrorHandler(ErrCode, ErrStr$, ErrCmd, ErrLine)
	SetTimeout(1, p_CustomErrorMessage, 500, {ErrCode, ErrStr$, ErrCmd, ErrLine})
EndFunction

RaiseOnError(p_ErrorHandler)

LoadBrush(1, "DoesNotExist")

Repeat
	WaitEvent
Forever

Re: RaiseOnError() with RapaGUI on Latest Android Player

Posted: Sun Jul 25, 2021 5:17 pm
by SamuraiCrow
@PEB
If SystemRequest() is the problem, wouldn't moai.Request() be preferred?

Re: RaiseOnError() with RapaGUI on Latest Android Player

Posted: Wed Jul 28, 2021 10:17 pm
by airsoftsoftwair
SamuraiCrow wrote: Sun Jul 25, 2021 5:17 pm @PEB
If SystemRequest() is the problem, wouldn't moai.Request() be preferred?
Won’t help because anything that starts a modal loop from within the error handler will trigger the error. PEB’s workaround is quite nice. An even better one would be to use RunCallback() instead of SetTimeout(). I haven’t tried it but it should work.

Re: RaiseOnError() with RapaGUI on Latest Android Player

Posted: Thu Jul 29, 2021 6:59 am
by PEB
Yes, RunCallback() does work and is better. Thanks for the suggestion!
(I keep forgetting to use that new function.) :oops: