Has the event timeout limit changed?

Creating scripts
User avatar
Dale Innis
Posts: 41
Joined: Thu Mar 13, 2014 1:59 am
Has thanked: 84 times
Been thanked: 49 times

Has the event timeout limit changed?

Post by Dale Innis »

I have a set of scripts that do lots of processing and waiting within a listen() event (which works fine, given the overall design), and I notice that as of sometime recently I am getting script errors like "Script restarted due to event timeout" or other words to that effect, and it does look like the scripts are restarting, which is not what I want or expect!

These particular scripts are just little swirly visuals and restarting them doesn't matter much; but I expect that I (and I'm sure lots of others) have other scripts that really don't want to be restarted just because they're spending time in an event handler. It may not be Best Practices For Scripts to spend two minutes or whatever in a handler, but if it works, it works. (Or has until now.)

Anyway, has this limit been imposed or reduced recently, and could it be put back to whatever it used to be?
These users thanked the author Dale Innis for the post:
Ilan Tochner
User avatar
Ilan Tochner
Posts: 6518
Joined: Sun Dec 23, 2012 8:44 am
Has thanked: 4970 times
Been thanked: 4469 times
Contact:

Re: Has the event timeout limit changed?

Post by Ilan Tochner »

Hi Dale,

The event timeout is 30 seconds, which is the OpenSim default.

From OpenSim.ini:

Code: Select all

    ;# {EventLimit} {} {Amount of time a script can spend in an event handler} {} 30
    ;; Time a script can spend in an event handler before it is interrupted
    ; EventLimit = 30
Since this is the standard across all of OpenSim we'll not change it, because then scripts that work in Kitely might not work in other grids.

We've never changed this timeout. However, in our March 19 (2020) release we started doing a better job of reporting scripts errors to our users. Before then only a subset of script errors were reported to you, and the rest were just written to the log, so you didn't even know that an error had occurred. So probably these timeouts have always occurred, but they've only started being shown in the viewer in the last few months.
These users thanked the author Ilan Tochner for the post (total 3):
Dale InnisGraham MillsChris Namaste
User avatar
Dale Innis
Posts: 41
Joined: Thu Mar 13, 2014 1:59 am
Has thanked: 84 times
Been thanked: 49 times

Re: Has the event timeout limit changed?

Post by Dale Innis »

Ah, thanks! In that case no scripts were probably broken. I should tour around and see if any existing ones have been getting reset for this reason all this time and I just didn't realize it! Might explain some things...

Thanks again for the helpful explanation!
These users thanked the author Dale Innis for the post (total 3):
Ilan TochnerKarima HoisanChris Namaste
User avatar
John Mela
Posts: 91
Joined: Tue Feb 04, 2014 9:50 pm
Has thanked: 139 times
Been thanked: 127 times
Contact:

Re: Has the event timeout limit changed?

Post by John Mela »

For what it's worth, I've long thought this limit is unfair (and Ilan is right, it's part of core OpenSim).

Consider someone who has a World that is full of badly-written scripts, badly-designed objects and so on. Their server's CPU is heavily impacted, but they don't really know or care - it works for them. They then buy one of our applications, and because of the other loads on their server, our app crashes from event timeouts. Of course, they're going to blame our app for generating these error messages.

We do a lot of testing and balancing on normally-loaded regions to ensure that no event lasts longer than around 10 seconds - one-third of the maximum - but there's absolutely nothing we can do to prevent events from lasting longer than that if the simulator is under heavy load.

If OpenSim limited the number of (say) instructions or function calls within an event, that would be reasonable. But to limit the elapsed time (which we as application developers have little control over), and then crash the application if that time is exceeded, means that no script writer can ever guarantee that it won't happen to their scripts.

And, of course, it's an obtrusive crash - every avatar in the region has a window pop up on their screen with an undecipherable (to most) message in virtually unreadable red-on-black.

One possible solution is for a script to monitor its own elapsed time in each event and exit gracefully if the limit is approached. This, of course, would simply add to the CPU overhead for given work, especially in cases where the time is spent iterating rapidly through a loop. For that reason, I've not implemented this, at least yet.

I'm not sure that there's anything that Kitely can reasonably do about this, but it's a concern that I think needs to be voiced.
These users thanked the author John Mela for the post:
Ilan Tochner
User avatar
Ilan Tochner
Posts: 6518
Joined: Sun Dec 23, 2012 8:44 am
Has thanked: 4970 times
Been thanked: 4469 times
Contact:

Re: Has the event timeout limit changed?

Post by Ilan Tochner »

Hi John,

Unless we decide to break compatibility with other OpenSim grids (which is something we really don't want to do) there is little we can do about this issue. Kitely provides world managers with web based monitoring of world CPU and network usage so they should be able to easily see the load their world has with and without your app. But that functionality isn't offered elsewhere so, I agree, people who run OpenSim outside Kitely are often unaware of how bad their setup is performing.
These users thanked the author Ilan Tochner for the post:
John Mela
User avatar
Gregg Legendary
Posts: 123
Joined: Sun Jun 22, 2014 10:22 am
Has thanked: 214 times
Been thanked: 211 times

Re: Has the event timeout limit changed?

Post by Gregg Legendary »

Hello, I have recently returned after a couple year absence and here is my situation,
I Run a script in my critters that plays multiple sounds each 10 seconds long which loops and repeats. I have been using this script for over a decade all over the os grid in sl and the old iwz ect ect... never had an issue with it before. Now here it fills th screen with nasty error messages :: sigh:: and restarts not playing all the sounds...From hat I understand here I never be able to run more than 3 sounds here with the 30 second limit unless I use multiple scripts sing even more region ie sim resources?
Am I correct or is there a work around?
These users thanked the author Gregg Legendary for the post:
Chris Namaste
User avatar
Ilan Tochner
Posts: 6518
Joined: Sun Dec 23, 2012 8:44 am
Has thanked: 4970 times
Been thanked: 4469 times
Contact:

Re: Has the event timeout limit changed?

Post by Ilan Tochner »

Hi Gregg,

Please copy/paste one of those error message here so that we can see what it's reporting.
These users thanked the author Ilan Tochner for the post:
Chris Namaste
User avatar
Gregg Legendary
Posts: 123
Joined: Sun Jun 22, 2014 10:22 am
Has thanked: 214 times
Been thanked: 211 times

Re: Has the event timeout limit changed?

Post by Gregg Legendary »

Roaming Bay Dun Quarter Horse: Restarting script due to event timeout (Script: "Sound on off 2", State: default, Prim: "Roaming Bay Dun Quarter Horse"/7d186809-b060-466b-82fd-13472a3ec984 at <359.1462, 66.1992, 23.32144>)
These users thanked the author Gregg Legendary for the post:
Chris Namaste
User avatar
Ilan Tochner
Posts: 6518
Joined: Sun Dec 23, 2012 8:44 am
Has thanked: 4970 times
Been thanked: 4469 times
Contact:

Re: Has the event timeout limit changed?

Post by Ilan Tochner »

Script timeouts are the same here as they are in any other OpenSim grid that runs the latest OpenSim release (currently 0.9.1.1) using the standard configuration.

The message you pasted mentions an event timeout, is your script creating an event that takes longer than 30 seconds to process? (setting a sound to be played should take a fraction of a second, not the duration of that sound). Have you tried using a timer-based approach, such as the one described here: https://avsitter.com/qa/95/scripting-ho ... -song.html ?
These users thanked the author Ilan Tochner for the post:
Chris Namaste
User avatar
Gregg Legendary
Posts: 123
Joined: Sun Jun 22, 2014 10:22 am
Has thanked: 214 times
Been thanked: 211 times

Re: Has the event timeout limit changed?

Post by Gregg Legendary »

It does use a timer event though set at 0.0
I will post the script here in the hopes something stands out that can be corrected to make it work as intended here

//•/•/•/•/•/•/•/Ð/A/M/E/N/•/H/A/X/•/•/•/•/•/•/•/•/•//

//Do not sell this; Karma knowz where you live ?

// How-to/Info:
// Put this script with some sound clips (numbered so they play in order)
// into a prim, then change the below values to suit your needs!!!
// Example, change the sound_length to match how long your sound clips are

float sound_length = 9.9;//How long the sound clips are
float sound_volume = 1.0;//from 0.00 to 1.00
float slow_server_adjustment = 0.01;//..
float text_alpha = 0.5;//how visible floating text is, from 0.00 to 1.00
vector text_color = <1,2,3>;//color of the floating text
integer num_sounds;//how many sound clips
integer active = FALSE;//Are we on/TRUE or off/FALSE
//list sound_list;// not needed for this job

loop_sounds(){
integer sound;//first sound in the inventory
for(; sound < num_sounds; ++sound){
//llOwnerSay((string)sound + " - "+llGetInventoryName(INVENTORY_SOUND, sound));
llTriggerSound(llGetInventoryName(INVENTORY_SOUND, sound), sound_volume);
llSleep(sound_length);
}
}

load_sounds(){
integer sound;
for(; sound < num_sounds; ++sound){
string s = llGetInventoryName(INVENTORY_SOUND, sound);
llSetText("• Preloading Sound • \n"+s, text_color, text_alpha);
llPreloadSound(s);
}llSetText(" ", text_color, text_alpha);
}

integer count_sounds(){
integer i;
integer n = llGetInventoryNumber(INVENTORY_SOUND);
list result = [];
for(i = 0; i < n; i++){
result += [llGetInventoryName(INVENTORY_SOUND, i)];
}//sound_list = result;
return llGetListLength(result);
}

string help = "• Help / Usage •
1. Load sounds into the prim that has this script inside.
2. Open the script and find the \"sound_length\" value.
3. Change that value to match how your sound clips are.
4. Touch the object, wait for the sounds to preload.. Done!

Note: Uncomment the line in the touch_event to make it \"owner only\".";

default{
//
state_entry(){
llSetText(" ", text_color, text_alpha);
}
//
changed(integer c){
if(c & CHANGED_OWNER){
llWhisper(0,"/me "+help);
llResetScript();
}
}
//
touch_start(integer total_number){
//if(llDetectedKey(0) != llGetOwner())return;//uncomment for owner only
active =! active;
if(active){
num_sounds = count_sounds();
load_sounds();
llSetTimerEvent((num_sounds * sound_length)-(num_sounds * slow_server_adjustment));
llWhisper(0,"/me • Playing.");
loop_sounds();
}else{
llSetTimerEvent(0.0);
llWhisper(0,"/me • Stopped.");
}
}
//
timer(){
loop_sounds();
}
//
}
These users thanked the author Gregg Legendary for the post:
Chris Namaste
Post Reply