Skip to content

Commit 11e8635

Browse files
authored
fix: fixed blui browser closure (#80)
1 parent ff34ed4 commit 11e8635

File tree

4 files changed

+16
-66
lines changed

4 files changed

+16
-66
lines changed

Source/Immutable/Private/Immutable/ImmutableSubsystem.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,16 @@ void UImmutableSubsystem::Initialize(FSubsystemCollectionBase& Collection)
3636
void UImmutableSubsystem::Deinitialize()
3737
{
3838
IMTBL_LOG_FUNCSIG
39+
3940
BrowserWidget = nullptr;
41+
4042
#if USING_BLUI_CEF
41-
IMTBL_LOG("Stopped BLUI event loop");
42-
ImtblBlui->StopBluiEventLoop();
43-
#endif
43+
ImtblBlui->ConditionalBeginDestroy();
4444
ImtblBlui = nullptr;
45+
#endif
46+
4547
Passport = nullptr;
48+
4649
#if PLATFORM_ANDROID | PLATFORM_IOS
4750
UGameViewportClient::OnViewportCreated().Remove(EngineInitCompleteHandle);
4851
#else

Source/Immutable/Private/Immutable/ImtblBlui.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ void UImtblBlui::OnLogEvent(const FString& LogText)
3636
void UImtblBlui::WorldTickStart(UWorld* World, ELevelTick LevelTick, float X)
3737
{
3838
#if USING_BLUI_CEF
39-
if (GetBluEye()->IsBrowserLoading()) {
40-
IMTBL_LOG("Waiting for Browser to load...");
41-
} else if (!bLoadedIndexJS) {
42-
bLoadedIndexJS = true;
39+
if (!GetBluEye()->IsBrowserLoading() && !bLoadedIndexJS) {
4340
const FSoftObjectPath AssetRef(
44-
TEXT("/Script/Immutable.ImtblSDKResource'/Immutable/PackagedResources/"
45-
"index.index'"));
41+
TEXT("/Script/Immutable.ImtblSDKResource'/Immutable/PackagedResources/"
42+
"index.index'"));
43+
44+
IMTBL_LOG("Browser loaded");
45+
bLoadedIndexJS = true;
4646
if (UObject *LoadedAsset = AssetRef.TryLoad()) {
4747
if (const auto Resource = Cast<UImtblSDKResource>(LoadedAsset)) {
4848
GetBluEye()->ExecuteJS(Resource->Js);
@@ -136,14 +136,15 @@ void UImtblBlui::Init()
136136
const FString CustomContentMethod(TEXT("X-GET-CUSTOM-CONTENT"));
137137

138138
const auto Request = CefRequest::Create();
139-
Request->Set("file://Immutable/index.html", *CustomContentMethod,
139+
Request->Set("file:///Immutable/index.html", *CustomContentMethod,
140140
PostData, HeaderMap);
141141

142142
GetBluEye()->Browser->GetMainFrame()->LoadRequest(Request);
143143
IMTBL_VERBOSE("LoadRequest'ed for Index.html")
144144

145145
WorldTickHandle = FWorldDelegates::OnWorldTickStart.AddUObject(
146146
this, &UImtblBlui::WorldTickStart);
147+
IMTBL_LOG("Waiting for Browser to load...");
147148
}
148149
}
149150
else

Source/Immutable/Private/Immutable/ImtblBrowserWidget.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ void UImtblBrowserWidget::SetBrowserContent()
9191
const FString IndexHtml = FString("<!doctype html><html lang='en'><head><meta " "charset='utf-8'><title>GameSDK Bridge</title><script>") + Resource->Js + FString("</script></head><body><h1>Bridge Running</h1></body></html>");
9292

9393
// IMTBL_LOG("Loaded resource: %s", *Resource->GetName())
94-
WebBrowserWidget->LoadString(IndexHtml, TEXT("file://immutable/index.html"));
94+
WebBrowserWidget->LoadString(IndexHtml, TEXT("file:///immutable/index.html"));
9595
// WebBrowserWidget->LoadURL(FString::Printf(TEXT("%s%s"),
9696
// TEXT("file:///"),
9797
// *FPaths::ConvertRelativePathToFull(FPaths::Combine(FPaths::ProjectContentDir(),

Source/Immutable/Private/ImmutableModule.cpp

Lines changed: 1 addition & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -30,61 +30,7 @@ void FImmutableModule::StartupModule()
3030
}
3131

3232
void FImmutableModule::ShutdownModule()
33-
{
34-
#if PLATFORM_WINDOWS && USING_BLUI_CEF
35-
DWORD aProcesses[1024], cbNeeded;
36-
unsigned int i;
37-
38-
if (EnumProcesses(aProcesses, sizeof(aProcesses), &cbNeeded))
39-
{
40-
// Calculate how many process identifiers were returned.
41-
DWORD cProcesses = cbNeeded / sizeof(DWORD);
42-
43-
// Print the name and process identifier for each process.
44-
for (i = 0; i < cProcesses; i++)
45-
{
46-
if (aProcesses[i] != 0)
47-
{
48-
TCHAR szProcessName[MAX_PATH] = TEXT("<unknown>");
49-
// Get a handle to the process.
50-
HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, 0, aProcesses[i]);
51-
DWORD errCode = GetLastError();
52-
53-
IMTBL_LOG("PID %d : ERROR %d ", aProcesses[i], errCode);
54-
// Get the process name.
55-
if (errCode == 0 && hProcess != NULL)
56-
{
57-
HMODULE hMod;
58-
59-
cbNeeded = 0;
60-
if (EnumProcessModules(hProcess, &hMod, sizeof(hMod), &cbNeeded))
61-
{
62-
if (GetModuleBaseName(hProcess, hMod, szProcessName, sizeof(szProcessName) / sizeof(TCHAR)))
63-
{
64-
if (!_tcscmp(szProcessName, _T("blu_ue4_process.exe")))
65-
{
66-
if (TerminateProcess(hProcess, 0) == 0)
67-
{
68-
IMTBL_ERR("Faild to shutdown BLUI executable process");
69-
}
70-
else
71-
{
72-
IMTBL_LOG("BLUI executable process terminated");
73-
}
74-
}
75-
}
76-
}
77-
errCode = GetLastError();
78-
79-
// Release the handle to the process.
80-
CloseHandle(hProcess);
81-
}
82-
}
83-
}
84-
}
85-
86-
#endif
87-
}
33+
{}
8834

8935
#undef LOCTEXT_NAMESPACE
9036

0 commit comments

Comments
 (0)