keijiro / OscJack

Lightweight C# implementation of OSC server/client
The Unlicense
476 stars 65 forks source link

Event receiver Adding a single string message to its queue twice #25

Closed polinski closed 3 years ago

polinski commented 3 years ago

Hi. I'm sending messages from Max to Unity via OSC Jack. Nothing particularly complicated, just single strings from Max that will get printed to a UI log in Unity.

These are one-time messages rather than continuous input. They appear in OSC Monitor once as expected, but for some reason they are hitting the Event Receiver component twice. I've tried to follow the chain of events back but it's beyond my coding skills. It looks like a single message is getting added to the queue twice: _stringQueue has a count of 2 after receiving a single message.

Any workarounds/suggestions would be much appreciated.

(Thanks for all your code, it's incredibly useful!)

polinski commented 3 years ago

(i should add, I tried this with Vector2/Int etc. as other data types instead of a string - the same thing happens. One single message from Max, appears once in OSC Monitor, but twice in the Event Receiver script).

keijiro commented 3 years ago

Could you provide a minimal project that reproduces the issue?

polinski commented 3 years ago

Sure thing, here you go: https://github.com/polinski/OscJackTestProject

Screenshot of the test Max patch I used that sends a single OSC message. In Unity, your OSC Monitor just receives it once, but the Event Receiver script appears to receive it twice.

(I also tested this Max patch with OSC Data Monitor to make sure it wasn't Max being weird. Everything seems normal there).

Screenshot 2021-01-31 at 15 27 18
keijiro commented 3 years ago

Thanks for sharing the project. I found that a change in OnValidate of the recent versions of Unity introduced the issue. I fixed the issue in the latest commit (7feec67). Please upgrade the package to 1.0.2.

polinski commented 3 years ago

Thank you!