-
Notifications
You must be signed in to change notification settings - Fork 6
Description
Unity, in a standalone player, randomly crashes when a new program starts sending texture with any name.
It doesn't matter if the object within Unity actually receives the texture (still happens with no matching shared name).
It doesn't happen every time, I must open and close the sending program a few times. Sometimes it happens in the first try, sometimes in the 3rd or 5th or later.
Sometimes, Unity just freezes, and you have to close it in the task manager.
Other times, it show a window blaming nvwgf2umx.dll or ntdll.dll.
After days trying everything I could, it seemed random every time I tried a new approach.
Then I noticed it didn't crash if I enabled the plugin console.
Then, it still crashed if I commented out the every printf call in the dll source, even with the console enabled.
I narrowed it down to the checkReceivers() function.
If at least this function has its printf calls and the console is enabled, Unity doesn't crash.
So I tried to add Sleep(10) to its beginning, compiled it, and that's it, no more crash, even with the console disabled!
I started from 1000ms, and 10ms is good. 1ms didn't help, still crashed.
Here's my code now:
extern "C" void EXPORT_API checkReceivers()
{
if (sender == nullptr) return;
int numSenders = sender->GetSenderCount();
if (numSenders != lastSendersCount)
{
// FIX UNITY CRASH!
Sleep(10);
printf("Num Senders changed : %i\n", numSenders);
UnitySenderUpdate(numSenders);
int i, j;
bool found;
printf("Old Sender List :\n");
etc...I have no idea what's happening, but that ugly hack did it (and I'm freaking happy now!).
I though reporting this here could help you guys figure out better what's the problem.
I'm using Windows 7 SP1, a GTX 650 Ti with lasted Nvidia drivers, and Unity 4.5.2f1.