You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
#lockdown Nick.Penwarden #rb none ========================== MAJOR FEATURES + CHANGES ========================== Change 3209340 on 2016/11/23 by Ben.Marsh Convert UE4 codebase to an "include what you use" model - where every header just includes the dependencies it needs, rather than every source file including large monolithic headers like Engine.h and UnrealEd.h. Measured full rebuild times around 2x faster using XGE on Windows, and improvements of 25% or more for incremental builds and full rebuilds on most other platforms. * Every header now includes everything it needs to compile. * There's a CoreMinimal.h header that gets you a set of ubiquitous types from Core (eg. FString, FName, TArray, FVector, etc...). Most headers now include this first. * There's a CoreTypes.h header that sets up primitive UE4 types and build macros (int32, PLATFORM_WIN64, etc...). All headers in Core include this first, as does CoreMinimal.h. * Every .cpp file includes its matching .h file first. * This helps validate that each header is including everything it needs to compile. * No engine code includes a monolithic header such as Engine.h or UnrealEd.h any more. * You will get a warning if you try to include one of these from the engine. They still exist for compatibility with game projects and do not produce warnings when included there. * There have only been minor changes to our internal games down to accommodate these changes. The intent is for this to be as seamless as possible. * No engine code explicitly includes a precompiled header any more. * We still use PCHs, but they're force-included on the compiler command line by UnrealBuildTool instead. This lets us tune what they contain without breaking any existing include dependencies. * PCHs are generated by a tool to get a statistical amount of coverage for the source files using it, and I've seeded the new shared PCHs to contain any header included by > 15% of source files. Tool used to generate this transform is at Engine\Source\Programs\IncludeTool. [CL 3209342 by Ben Marsh in Main branch]
269 lines
7.2 KiB
C++
269 lines
7.2 KiB
C++
// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "CoreMinimal.h"
|
|
#include "Misc/CoreDelegates.h"
|
|
#include "Modules/ModuleManager.h"
|
|
#include "Interfaces/ICrashTrackerModule.h"
|
|
#include "HAL/FileManager.h"
|
|
#include "Misc/CommandLine.h"
|
|
#include "Misc/Paths.h"
|
|
#include "Logging/EventLogger.h"
|
|
#include "Framework/Application/SlateApplication.h"
|
|
#include "CrashVideoCapture.h"
|
|
#include "RHI.h"
|
|
|
|
#if (PLATFORM_WINDOWS || PLATFORM_MAC) && !UE_BUILD_MINIMAL
|
|
#define CRASH_TRACKER_SUPPORTED 1
|
|
#else
|
|
#define CRASH_TRACKER_SUPPORTED 0
|
|
#endif
|
|
|
|
|
|
/** Logs keypresses to the crash tracker, as well as triggering it's completion upon a crash */
|
|
class FCrashTrackerEventLogger : public FStabilityEventLogger
|
|
{
|
|
public:
|
|
FCrashTrackerEventLogger(TSharedPtr<FCrashVideoCapture> InVideoCapture = NULL);
|
|
|
|
virtual void Log(EEventLog::Type Event, const FString& AdditionalContent, TSharedPtr<SWidget> Widget) override;
|
|
|
|
void OnHandleError();
|
|
void OnHandleEnsure();
|
|
|
|
private:
|
|
TWeakPtr<FCrashVideoCapture> VideoCapture;
|
|
};
|
|
|
|
|
|
FCrashTrackerEventLogger::FCrashTrackerEventLogger(TSharedPtr<FCrashVideoCapture> InVideoCapture)
|
|
: VideoCapture(InVideoCapture)
|
|
{
|
|
}
|
|
|
|
|
|
void FCrashTrackerEventLogger::Log(EEventLog::Type Event, const FString& AdditionalContent, TSharedPtr<SWidget> Widget)
|
|
{
|
|
FStabilityEventLogger::Log(Event, AdditionalContent, Widget);
|
|
|
|
if (VideoCapture.IsValid())
|
|
{
|
|
if (Event == EEventLog::KeyDown)
|
|
{
|
|
check(AdditionalContent.Len());
|
|
VideoCapture.Pin()->BufferKeyPress(AdditionalContent);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
void FCrashTrackerEventLogger::OnHandleError()
|
|
{
|
|
UE_LOG(LogCrashTracker, Log, TEXT("%s"), *GetLog());
|
|
|
|
if (VideoCapture.IsValid())
|
|
{
|
|
// Finish capturing video
|
|
VideoCapture.Pin()->EndCapture(/*bSaveCapture=*/true);
|
|
}
|
|
}
|
|
|
|
|
|
void FCrashTrackerEventLogger::OnHandleEnsure()
|
|
{
|
|
if (VideoCapture.IsValid())
|
|
{
|
|
// Capture video for the ensure
|
|
VideoCapture.Pin()->SaveCaptureNow(VideoCapture.Pin()->CaptureVideoPath);
|
|
}
|
|
}
|
|
|
|
|
|
class FCrashTrackerModule
|
|
: public ICrashTrackerModule
|
|
{
|
|
public:
|
|
|
|
// IModuleInterface interface
|
|
|
|
virtual void StartupModule() override;
|
|
virtual void ShutdownModule() override;
|
|
|
|
public:
|
|
|
|
// ICrashTracker interface
|
|
|
|
virtual void Update(float DeltaSeconds) override;
|
|
virtual void ForceCompleteCapture() override;
|
|
virtual void SetCrashTrackingEnabled(bool bEnabled) override;
|
|
virtual bool IsVideoCaptureAvailable() const override;
|
|
virtual bool IsCurrentlyCapturing() const override;
|
|
virtual void InvalidateCrashTrackerFrame() override;
|
|
virtual EWriteUserCaptureVideoError::Type WriteUserVideoNow( FString& OutFinalSaveName ) override;
|
|
|
|
private:
|
|
|
|
// The video capture instance
|
|
TSharedPtr<FCrashVideoCapture> VideoCapture;
|
|
|
|
// The event logger instance
|
|
TSharedPtr<FCrashTrackerEventLogger> EventLogger;
|
|
};
|
|
|
|
|
|
void FCrashTrackerModule::StartupModule()
|
|
{
|
|
FCrashVideoCapture::CaptureVideoPath = FPaths::GameLogDir() + TEXT("CrashVideo.avi");
|
|
|
|
// kill it just in case it's hanging around from last session's capture
|
|
IFileManager::Get().Delete(*FCrashVideoCapture::CaptureVideoPath);
|
|
|
|
VideoCapture.Reset();
|
|
#if CRASH_TRACKER_SUPPORTED
|
|
if (GIsEditor &&
|
|
(GMaxRHIShaderPlatform == SP_PCD3D_SM4 || GMaxRHIShaderPlatform == SP_PCD3D_SM5 || GMaxRHIShaderPlatform == SP_OPENGL_SM4 || GMaxRHIShaderPlatform == SP_OPENGL_SM4_MAC))
|
|
{
|
|
bool bCrashTrackerShouldBeEnabled = false;
|
|
#if UE_BUILD_DEVELOPMENT
|
|
// Disable crash tracker by default for now unless someone enables it.
|
|
// bCrashTrackerShouldBeEnabled =
|
|
// !GIsDemoMode &&
|
|
// !FParse::Param( FCommandLine::Get(), TEXT("disablecrashtracker") ) &&
|
|
// !FApp::IsBenchmarking() &&
|
|
// !FPlatformMisc::IsDebuggerPresent();
|
|
#endif
|
|
bool bForceEnableCrashTracker = FParse::Param( FCommandLine::Get(), TEXT("forceenablecrashtracker") );
|
|
|
|
if (bCrashTrackerShouldBeEnabled || bForceEnableCrashTracker)
|
|
{
|
|
VideoCapture = MakeShareable(new FCrashVideoCapture);
|
|
}
|
|
}
|
|
#endif //CRASH_TRACKER_SUPPORTED
|
|
|
|
EventLogger = MakeShareable( new FCrashTrackerEventLogger(VideoCapture) );
|
|
FSlateApplication::Get().SetSlateUILogger(EventLogger);
|
|
// hook up event logger to global assert/ensure hook
|
|
FCoreDelegates::OnHandleSystemEnsure.AddRaw(EventLogger.Get(), &FCrashTrackerEventLogger::OnHandleEnsure);
|
|
FCoreDelegates::OnHandleSystemError.AddRaw(EventLogger.Get(), &FCrashTrackerEventLogger::OnHandleError);
|
|
|
|
if (VideoCapture.IsValid())
|
|
{
|
|
UE_LOG(LogCrashTracker, Log, TEXT("Crashtracker beginning capture."));
|
|
VideoCapture->BeginCapture(FSlateApplication::Get().GetRenderer().Get());
|
|
}
|
|
else
|
|
{
|
|
UE_LOG(LogCrashTracker, Log, TEXT("Crashtracker disabled due to settings."));
|
|
}
|
|
}
|
|
|
|
|
|
void FCrashTrackerModule::ShutdownModule()
|
|
{
|
|
// Make sure we remove the hook to prevent calling this when it's garbage
|
|
FCoreDelegates::OnHandleSystemEnsure.RemoveAll(EventLogger.Get());
|
|
FCoreDelegates::OnHandleSystemError.RemoveAll(EventLogger.Get());
|
|
|
|
VideoCapture.Reset();
|
|
}
|
|
|
|
|
|
void FCrashTrackerModule::Update(float DeltaSeconds)
|
|
{
|
|
if (VideoCapture.IsValid())
|
|
{
|
|
VideoCapture->Update(DeltaSeconds);
|
|
}
|
|
}
|
|
|
|
|
|
void FCrashTrackerModule::ForceCompleteCapture()
|
|
{
|
|
if (VideoCapture.IsValid())
|
|
{
|
|
VideoCapture->EndCapture(/*bSaveCapture=*/true);
|
|
check(0);
|
|
}
|
|
}
|
|
|
|
|
|
void FCrashTrackerModule::SetCrashTrackingEnabled(bool bEnabled)
|
|
{
|
|
if (VideoCapture.IsValid())
|
|
{
|
|
VideoCapture->SetCrashTrackingEnabled(bEnabled);
|
|
}
|
|
}
|
|
|
|
|
|
bool FCrashTrackerModule::IsVideoCaptureAvailable() const
|
|
{
|
|
return VideoCapture.IsValid();
|
|
}
|
|
|
|
|
|
bool FCrashTrackerModule::IsCurrentlyCapturing() const
|
|
{
|
|
return VideoCapture.IsValid() && VideoCapture->IsCapturing();
|
|
}
|
|
|
|
|
|
void FCrashTrackerModule::InvalidateCrashTrackerFrame()
|
|
{
|
|
if (VideoCapture.IsValid())
|
|
{
|
|
VideoCapture->InvalidateFrame();
|
|
}
|
|
}
|
|
|
|
|
|
EWriteUserCaptureVideoError::Type FCrashTrackerModule::WriteUserVideoNow( FString& OutFinalSaveName )
|
|
{
|
|
EWriteUserCaptureVideoError::Type WriteResult = EWriteUserCaptureVideoError::None;
|
|
if(VideoCapture.IsValid())
|
|
{
|
|
// Check if the capture is running and try to create the video capture folder.
|
|
if( !VideoCapture->IsCapturing() )
|
|
{
|
|
WriteResult = EWriteUserCaptureVideoError::CaptureNotRunning;
|
|
}
|
|
else if( !IFileManager::Get().MakeDirectory( *FPaths::VideoCaptureDir(), true ) )
|
|
{
|
|
WriteResult = EWriteUserCaptureVideoError::FailedToCreateDirectory;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
WriteResult = EWriteUserCaptureVideoError::VideoCaptureInvalid;
|
|
}
|
|
|
|
// If there was no error find a suitable filename and write the file.
|
|
if( WriteResult == EWriteUserCaptureVideoError::None )
|
|
{
|
|
// The final save name
|
|
OutFinalSaveName = "";
|
|
// have we got a name
|
|
bool bGotName = false;
|
|
// Counter used to build filename
|
|
int32 SaveNameCount = 1;
|
|
while( bGotName == false )
|
|
{
|
|
// Build a name from the video capture path and an incrementing count
|
|
OutFinalSaveName = FString::Printf(TEXT("%s_%02d.avi"), *(FPaths::VideoCaptureDir() + TEXT("CaptureVideo" ) ) , SaveNameCount );
|
|
// FileSize returns INDEX_NONE if the file doesn't exist
|
|
if( IFileManager::Get().FileSize( *OutFinalSaveName ) == INDEX_NONE )
|
|
{
|
|
bGotName = true;
|
|
}
|
|
// Try another filename
|
|
SaveNameCount++;
|
|
}
|
|
// We now have a filename - write the video. This can only return false if the capture is not running - and we already checked for that
|
|
VideoCapture->SaveCaptureNow( OutFinalSaveName );
|
|
}
|
|
return WriteResult;
|
|
}
|
|
|
|
|
|
IMPLEMENT_MODULE(FCrashTrackerModule, CrashTracker);
|