#libWrapper register and unregister

1 messages ยท Page 1 of 1 (latest)

drowsy glen
#

Can you confirm what you mean by "disable the module"? That usually implies a restart, but you wouldn't need unregister in that case.
Is it a setting that doesn't require restart, or something?

#

Do you have other modules enabled?
Does anything show up as a conflict in libWrapper's config window ("Conflicts" pane)?
Are there other active wrappers in the TOKEN_DRAG_START method (see the libWrapper config window "Active Wrappers" pane)? Does your module show up there after re-registering it?

plucky narwhal
drowsy glen
#

makes sense. Can you check the other things I asked? Trying to figure out if it's something wrong with libWrapper, or a conflict with another module, or whatever

#

there's a bunch of unit tests around register/unregister so I wouldn't expect it to be a libWrapper bug, but who knows. The real world is sometimes not the same as unit tests ๐Ÿ˜…

plucky narwhal
#

otherwise, for your other points, i checked and my module is the only one in the libWrapper list and no conflict shown (even after reload)

#

but for some reason, i can't re-register a wrapper for CONFIG.Token.objectClass.prototype._onDragLeftStart

#

i see no errors

#

while the other wrapper works fine

drowsy glen
#

does it show up in the "Active Wrappers" tab?

plucky narwhal
#

it does oO

drowsy glen
#

is it the only one?

plucky narwhal
#

both

drowsy glen
#

It shows up after the register/unregister/register, right? And it's the only wrapper in that method?

#

can you paste a screenshot of the active wrappers tab with both methods expanded? ACTOR_DERIVED_DATA and TOKEN_DRAG_START

plucky narwhal
#

for some reason, they are still there even after i unregister them

drowsy glen
#

hmm, and do they show up doubled when you re-register them?

plucky narwhal
#

and if i click on the "reload" button there and re-active my module, then i get an error

plucky narwhal
drowsy glen
#

what libWrapper version do you have?

plucky narwhal
#

ok it was just a refresh issue with libWrapper window, they are actually gone when i disable the module

drowsy glen
#

ah yeah you need to refresh, it doesn't poll

plucky narwhal
#

and now they are still there :/

#

it is inconsistant

drowsy glen
#

and you don't see anything in the console from libWrapper?

plucky narwhal
#

libWrapper clearly says that it is registering the events

drowsy glen
#

yeah...

plucky narwhal
#

but only one is working

drowsy glen
#

do you see the wrapper called if you call the method manually on an actor?

plucky narwhal
#

gonna test on another system

drowsy glen
#

e.g. try CONFIG.Actor.objectCall.prototype._onDragLeftStart.call(null)

#

(it will probably fail at some point because of this being null, but I'm interested if you see your message)

plucky narwhal
#

not working on another system either, so it is not that

plucky narwhal
#

how weird is that

drowsy glen
#

ok, so that removes the most obvious failure case

#

are you sure whatever code you're relying on is actually calling it?

plucky narwhal
#

it is a token drag on the canvas

#

i am not calling it

drowsy glen
#

I can think of a few things that could be going wrong, but they all depend on someone else (the caller) doing something weird

plucky narwhal
#

i am not in control of anything here, it is just a drag event

drowsy glen
#

yeah, but are we sure it is calling this drag event

#

I'm wondering if it's possible it's not this class or something

plucky narwhal
#

it is on the first register though

drowsy glen
#

yeah but it could be superclassed or something fancy

#

the problem is that without seeing the caller I'm not sure how to debug the issue

plucky narwhal
#

PlaceableObject maybe instead of token ?

drowsy glen
#

because if calling it directly works, the only ideas I have relate to either weird superclassing, non-libWrapper wrappers (wouldn't be a libWrapper bug), or a bug in the libWrapper handler mechanism

plucky narwhal
#

PlaceableObject.prototype._onDragLeftStart seem to be working

drowsy glen
#

ok, let's try this

plucky narwhal
#

i need to check for type now

drowsy glen
#

in the console, before unregistering, type this:
Object.getOwnPropertyDescriptor(CONFIG.Actor.objectCall.prototype, "_onDragLeftStart").get._lib_wrapper

#

then unregister, type it again

#

then re-register, type it again

#

give me the outputs

#

make sure to expand the getter_data field of the resulting object

plucky narwhal
#

hmm CONFIG.Actor.objectCall.prototype why that ?*

drowsy glen
#

oops

#

CONFIG.Token.objectClass.prototype

#

typo ๐Ÿ˜‚

#

Object.getOwnPropertyDescriptor(CONFIG.Token.objectClass.prototype, "_onDragLeftStart").get._lib_wrapper

plucky narwhal
#

so you want me to go back and register with CONFIG.Token.objectClass.prototype._onDragLeftStart ?

drowsy glen
#

yeah, just give me the three views of that object, and expand getter_data

#

should give you something like this

#

also, I didn't ask, but do you have high performance mode enabled in the settings? Can you try toggling it?

plucky narwhal
#

getting an error actually

#

i don't understand why

#

it is clearly there

#

and my code works fine right now (i haven't disabled anything yet)

drowsy glen
#

what's the output of just the first part?

#

Object.getOwnPropertyDescriptor(CONFIG.Token.objectClass.prototype, "_onDragLeftStart")

plucky narwhal
#

well the error says undefined

#

but if i switch to PlaceableObject.prototype._onDragLeftStart

#

it works

drowsy glen
#

ok, that's your answer then

#

CONFIG.Token.objectClass is being replaced after you register your wrappers...

plucky narwhal
#

yeah, it is working with that wrapper

#

i can enable, disable and re-enable now

#

with PlaceableObject.prototype._onDragLeftStart

drowsy glen
#

and the libWrapper bug is that it doesn't distinguish that they're different objects in the UI, since they have the same "name"

plucky narwhal
#

man, that was such a landmine, no way to foreshadow it

#

thanks a lot

drowsy glen
#

sure, I'll see what I can do to at least make it more obvious

#

I suspect if you had made the unregister fail, you'd have gotten an exception saying it wasn't found

#

ah wait, no, unregister uses a hashtable based on the name, rather than going to the object

#

I probably should change that

plucky narwhal
#

^^

#

debugging is not my forte

#

i think i would have tried the PlaceableObject.prototype._onDragLeftStart at some point but i learn few things thanks to you

drowsy glen
#

I'll probably modify the libWrapper API to allow returning an ID, and unregistering by ID

#

then make the unregistering by string actually walk the string, rather than using the hashtable

#

and in the Active Wrappers UI I'll distinguish by ID, not just by name

#

thanks for the report / help too

drowsy glen
#

@plucky narwhal v1.11.0.0 now supports the aforementioned unique target identifiers, and displays a numeric ID in the settings pane. It will also display the two methods separately and with different target IDs, making what was going on much more obvious.