internal void Update() { try { if (messages != null) { messages.ProcessOutboundQueue(); ConsumeMessage(); CheckForTimeout(); } } catch (AccessViolationException) { // We run into an access violation when Unity disposes the // shared memory buffer but Blender is still trying to do IO with it. // So we explicitly catch this case and gracefully disconnect. // See: https://docs.microsoft.com/en-us/dotnet/api/system.runtime.exceptionservices.handleprocesscorruptedstateexceptionsattribute#remarks // TODO: IDEALLY - this should happen closer to the IO with the shared memory buffer, // as doing it here might catch access violations elsewhere in the library that weren't // intended since this method essentially wraps EVERYTHING. // Possibly @ RpcMessenger.Read/Write? Or deeper in CircularBuffer.Read/Write. // Actual exception for Read was thrown within CircularBuffer.ReturnNode InteropLogger.Error($"Access Violation doing IO to the shared memory - disconnecting"); Disconnect(); } }
public static void SetLastError(Exception e) { InteropLogger.Error(e.ToString()); LastError = e.ToString(); }