Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0007345opensim[REGION] Script Functionspublic2014-10-08 10:262015-06-13 15:00
ReporterMata Hari 
Assigned ToDiva 
PrioritynormalSeveritymajorReproducibilityalways
StatusclosedResolutionfixed 
PlatformIntel i7 930 quad coreOSWindows .NETOS VersionWin7 x64
Product Versionmaster (dev code) 
Target VersionFixed in Version 
Summary0007345: Attach event does not trigger correctly on detach
DescriptionPer the LSL Wiki (http://wiki.secondlife.com/wiki/Attach [^])

"When detached to inventory, an object is only given limited time to execute its attach events. If these events are active when the script derezzes but have not completed, execution will finish when the object is next rezzed."

In my testing with OpenSim 0.8.1 cbd428c 2014-10-04 it would appear that the attach event is *never* processed until the object is next attached, at which point it first executes the detach (presumably stored queued in script state) and then the attach. I have tested this in a completely empty sandbox region with 0 prims, 0 scripts, and only me logged in so the script should have more than enough time to execute the detach at the time it occurs.
Steps To ReproduceRez a prim and put this in it

default
{
    attach(key who)
    {
        llOwnerSay("Processing attach event triggered with key value: "+who);
    }
}

Pick up and attach the prim. As you'll see, the event will only ever trigger when newly attaching it at which point you'll see it double-processed.
TagsNo tags attached.
Git Revision or version number
Run Mode Standalone (Multiple Regions)
Physics EngineBulletSim
Environment.NET / Windows64
Mono VersionNone
ViewerFS 4.6.7 (42398) OS vers
Attached Filespatch file icon FixDetachEvent_v2.patch [^] (1,584 bytes) 2015-05-25 17:57 [Show Content]

- Relationships
related to 0006592closed Attach event not firing on detach 
related to 0005897closedmelanie attach(NULL_KEY) event not fired on detach. Event lost, or fired on next attach. 

-  Notes
(0026885)
Mata Hari (reporter)
2014-10-08 10:32

I should mention that the reason for marking this a major issue is that it's a problem when scripting something like an AO or other attachment that animates the agent who wears it. When the object is detached ideally you want to have it release animations rather than having to require the user to first turn it off somehow prior to detaching or be forced to use their viewer to revoke permissions and stop them.
(0028445)
AliciaRaven (manager)
2015-05-25 16:53

At this time, the detach event does nothing until reattached. It has been said that this problem can not be fixed with the current architecture of the script engine. This was not an option for me, i need this event to reliably fire when a scripted object is detached. The patch I have added here is not ideal but better than nothing.
(0028446)
Diva (administrator)
2015-05-25 19:26
edited on: 2015-05-25 19:43

Can someone please test if a Thread.Yield will do the job? I hate placing hardcoded sleeps in the code. I'm guilty of that too, but it should be the last resort...

Also, the proposed fix seems to be in a generic place. Could this be fixed in LSL_Api DetachWrapper?

(0028447)
AliciaRaven (manager)
2015-05-25 19:43

default
{
    state_entry()
    {
        llSay(0, "Script running");
    }
    
    attach(key id)
    {
        if(id == NULL_KEY)
        {
            llSay(0, "Detached Object");
        }
        else
        {
            llSay(0, "Attached Object");
        }
    }
}
(0028448)
AliciaRaven (manager)
2015-05-25 20:51

I have tested with Yield and in most cases this still does not fire the event on detach. I believe this is because the thread only yields to other threads on the same core.

Also placing the sleep anywhere else such as LSL_Api and DetachWrapper, would not work because the pause needs to be after adding the event to the queue but before the script state is stopped. This means it must be right in the middle of the 'PrepareScriptInstanceForSave' method.

An additional note. While testing I added a large sleep time to allow me to check if any noticeable side effects showed up for other avatars in the region. While the avatar that was detaching the item was locked up in this state, another avatar in the region could fly round freely with no lag so I'm pretty sure only the avatar detaching is affected by the extra 2 millisecond delay.
(0028452)
Diva (administrator)
2015-05-26 15:09

[15:07] <cia-opensim> opensim: alicia * r5e09e52ee99a OpenSim/Region/CoreModules/Avatar/Attachments (AttachmentsModule.cs):
[15:07] <cia-opensim> Attachments Module. Fix detach event not being fired until the next time the object is attached.
[15:07] <cia-opensim>
[15:07] <cia-opensim> Not an ideal fix but this allows scripts such as AOs to remove animations when detached etc. The pause added does not affect other avatars or the scene in general and only pauses the avatar performing the detach for an extra 2 milliseconds.

- Issue History
Date Modified Username Field Change
2014-10-08 10:26 Mata Hari New Issue
2014-10-08 10:32 Mata Hari Note Added: 0026885
2015-05-25 16:53 AliciaRaven File Added: FixDetachEvent.patch
2015-05-25 16:53 AliciaRaven Note Added: 0028445
2015-05-25 16:55 AliciaRaven Status new => patch included
2015-05-25 17:07 AliciaRaven Relationship added related to 0006592
2015-05-25 17:07 AliciaRaven Relationship added related to 0005897
2015-05-25 17:57 AliciaRaven File Added: FixDetachEvent_v2.patch
2015-05-25 17:57 AliciaRaven File Deleted: FixDetachEvent.patch
2015-05-25 19:26 Diva Note Added: 0028446
2015-05-25 19:43 AliciaRaven Note Added: 0028447
2015-05-25 19:43 Diva Note Edited: 0028446 View Revisions
2015-05-25 20:51 AliciaRaven Note Added: 0028448
2015-05-26 15:08 Diva Assigned To => Diva
2015-05-26 15:08 Diva Status patch included => assigned
2015-05-26 15:09 Diva Note Added: 0028452
2015-05-26 15:09 Diva Status assigned => resolved
2015-05-26 15:09 Diva Resolution open => fixed
2015-06-13 15:00 Diva Status resolved => closed


Copyright © 2000 - 2012 MantisBT Group
Powered by Mantis Bugtracker