Open LunaTheFoxgirl opened 1 year ago
It looks like this is using the overload of requestHTTP
that returns the response instead of the one that passes it as scope
to a callback. If that call is directly in your code, you could probably replace it with the scope
version to work around the crash.
For the crash itself, it looks like might be an order-of-destruction issue, where the GC destroys the referenced ConnectionPool
prior to the LockedConnection
that is as part of the HTTPClientResponse
. I'm not sure whether there is a simple fix (backwards compatible) within the library to avoid that, or if this is an obligation that needs to be passed to the user for now.
In the latter case, it would be necessary to catch the exception, either directly, or indirectly using a scope (failure)
guard, and call HTTPClientResponse.disconnect()
to ensure the response object frees any associated resources in time.
It looks like this is using the overload of requestHTTP that returns the response instead of the one that passes it as scope to a callback. If that call is directly in your code, you could probably replace it with the scope version to work around the crash.
Sadly no, I do not directly make the requestHTTP call, that is being done by connectWebSocket
Okay, then there is also an overload of connectWebSocket
that takes a WebSocketHandshakeDelegate
that internally uses the other connectHTTP
overload. I'll have a look at the exception handling in the web socket module later.
From what I can tell, I can't use the scope callback as the socket has to be a long lived object that is queried in a loop in things like games.
Having it long lived shouldn't be an issue, the task is light-weight and as long as it doesn't perform heavy computations, it shouldn't interfere with anything else in the main thread. The task could then be connected to other tasks/threads by establishing a two-way communication channel, which, in contrast to std.concurrency
, is strongly typed and doesn't allocate for each message.
I would need to figure out how to start/stop it on command, seems difficult considering how scope will destroy the object after it exits the scope
Channel
has a close
method and is reference counted (a copy would exist on both sides), so that could be used to safely communicate the end of the connection/scope.
Currently working on https://github.com/Inochi2D/vts-d
The example program segfaults if VTube Studio is closed and the WebSocket Server as a result stops sending data or if for some other reason data doesn't arrive properly. In the log there's a
WARNING: HTTPClientResponse not fully processed before being finalized
warning before the crashExample Program
LLDB Backtrace