chgatla-microsoft / QRTracking

MRTK sample app for QRtracking
MIT License
74 stars 69 forks source link

Threading issues #21

Closed TheRisenPhoenix closed 3 years ago

TheRisenPhoenix commented 3 years ago

I'm not sure whether this belongs here or whether I'm doing something incredibly wrong, but I've got some issues related to the events the QRCodeWatcher is firing. It looks like they are firing from different threads, one thread each per recognized QR Code. This leads to a couple of problems in the rest of my code, especially when GameObjects (their MonoBehaviours) are involved and should do something when a QR Code was recognized. Appaerently, methods can only be correctly invoked from within the main thread. Is anybody else having these kind of problems? Anyone knows a way around it?

Xan2063 commented 3 years ago

I can think of 3 ways to solve this:

TheRisenPhoenix commented 3 years ago

I solved it similar to your first suggestion. I was just wondering whether this is intentional by the library

Xan2063 commented 3 years ago

I think the qr codes are processed by IO threads where every threads processes a single frame. So I think this is intentional, else you would block the UI thread a lot