Download

UE 4.26 - Pixel Streaming Crash after SignallingWebServer disconnection

On Unreal Engine 4.26 if the SignallingWebServer disconnected the application crash on KeepAlive Function.



[2020.12.17-17.31.27:364][133]LogPixelStreamingSS: Connection to SS closed:
status 1006
reason:
was clean: 0
[2020.12.17-17.31.27:364][133]LogPixelStreamingSS: Connecting to SS ws://forlihome.ddns.net:8888
[2020.12.17-17.31.48:047][674]LogPixelStreamingSS: Error: Failed to connect to SS:
[2020.12.17-17.31.48:048][674]LogPixelStreamingSS: Connecting to SS ws://forlihome.ddns.net:8888
The thread 0x5cc4 has exited with code 0 (0x0).
[2020.12.17-17.32.09:013][194]LogPixelStreamingSS: Error: Failed to connect to SS:
[2020.12.17-17.32.09:013][194]LogPixelStreamingSS: Connecting to SS ws://forlihome.ddns.net:8888
Exception thrown at 0x00007FF7D0991E39 in RealEstateVisualizer-Win64-DebugGame.exe: 0xC0000005: Access violation reading location 0xFFFFFFFFFFFFFFFF.

Unhandled exception at 0x00007FF7D0991E39 in RealEstateVisualizer-Win64-DebugGame.exe: 0xC0000005: Access violation reading location 0xFFFFFFFFFFFFFFFF.


keepalive.png

The crash happens on Plugins\Media\PixelStreaming\Source\PixelStreaming\Private\SignallingServerConnection.cpp on 165 line of the KeepAlive method:



void FSignallingServerConnection::KeepAlive()
{
    auto Json = MakeShared<FJsonObject>();
    double unixTime = FDateTime::UtcNow().ToUnixTimestamp();
    Json->SetStringField(TEXT("type"), TEXT("ping"));
    Json->SetNumberField(TEXT("time"), unixTime);

    FString Msg = ToString(Json, false);

    if (WS.IsValid() && WS->IsConnected()) // Here line 165
    {
        WS->Send(Msg);
    }
}


The KeepAlive method is called by a SetTimer function, KeepAlive is a private and the class is not UObject.



void FSignallingServerConnection::OnConnected()
{
    UE_LOG(LogPixelStreamingSS, Log, TEXT("Connected to SS"));

    //Send message to keep connection alive every 60 seconds
    GWorld->GetTimerManager().SetTimer(TimerHandle_KeepAlive, std::bind(&FSignallingServerConnection::KeepAlive, this), KEEP_ALIVE_INTERVAL, true);
}


The KeepAlive method is even called after the ClearTimer on OnClosed:



void FSignallingServerConnection::OnClosed(int32 StatusCode, const FString& Reason, bool bWasClean)
{
    UE_LOG(LogPixelStreamingSS, Log, TEXT("Connection to SS closed: 
	status %d
	reason: %s
	was clean: %d"), StatusCode, *Reason, bWasClean);
    Observer.OnSignallingServerDisconnected();
    GWorld->GetTimerManager().ClearTimer(TimerHandle_KeepAlive);
}


Hi Feanor, we’re encountering the same crash in the KeepAlive function. Have you had any success with fixing this issue?