-
Notifications
You must be signed in to change notification settings - Fork 64
[Fix] Exit Stream Navigation #248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
000406d
fe68c3d
8db7bbe
1466a6d
c46d6eb
b01bf21
3170956
79a787f
2c396cd
7d7f464
ebfd591
21750e9
fec0177
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -82,7 +82,8 @@ | |||||
| <Grid x:Name="ProgressView" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"> | ||||||
| <StackPanel x:Name="ProgressStack" HorizontalAlignment="Center" VerticalAlignment="Center" Orientation="Vertical"> | ||||||
| <muxc:ProgressRing x:Name="MainProgressRing" Width="64" Height="64" IsActive="True" Margin="0,0,0,16" /> | ||||||
| <TextBlock x:Name="StatusText" Text="Initializing Moonlight..."/> | ||||||
| <TextBlock x:Name="StatusText" TextAlignment="Center" Text="Initializing Moonlight..."/> | ||||||
| <TextBlock x:Name="StepText" FontSize="12px" Foreground="DimGray" TextAlignment="Center" Text="" Margin="0,16,0,0" /> | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🌐 Web query:
💡 Result: UWP XAML does not support a Use: <TextBlock FontSize="12" />Related documentation:
Sources
Citations:
In UWP XAML, Proposed fix- <TextBlock x:Name="StepText" FontSize="12px" Foreground="DimGray" TextAlignment="Center" Text="" Margin="0,16,0,0" />
+ <TextBlock x:Name="StepText" FontSize="12" Foreground="DimGray" TextAlignment="Center" Text="" Margin="0,16,0,0" />📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
| </StackPanel> | ||||||
| </Grid> | ||||||
| </Grid> | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -71,50 +71,28 @@ void StreamPage::Page_Loaded(Platform::Object ^ sender, Windows::UI::Xaml::Route | |
| Utils::Log("StreamPage::Page_Loaded: SetSwapChainPanel failed\n"); | ||
| } | ||
|
|
||
| // Defer heavy initialization so the handler returns and the UI can present. | ||
| // Use a low-priority dispatch so the framework can complete the first frame. | ||
| Platform::WeakReference weakThis(this); | ||
| auto ignore = this->Dispatcher->RunAsync(CoreDispatcherPriority::Low, ref new DispatchedHandler([weakThis]() { | ||
| DISPATCH_UI([weakThis] { | ||
| auto that = weakThis.Resolve<StreamPage>(); | ||
| if (that == nullptr) return; | ||
| try { | ||
| that->m_main = std::unique_ptr<moonlight_xbox_dxMain>(new moonlight_xbox_dxMain(that->m_deviceResources, that, new MoonlightClient(), that->configuration)); | ||
|
|
||
| DISPATCH_UI([that], { | ||
| try { | ||
| that->m_main->CreateDeviceDependentResources(); | ||
| that->m_main->CreateWindowSizeDependentResources(); | ||
| that->m_main->StartRenderLoop(); | ||
| } catch (...) { | ||
| Utils::Log("StreamPage: init failed\n"); | ||
| } | ||
| }); | ||
|
|
||
| } catch (const std::exception &ex) { | ||
| Windows::UI::Xaml::Controls::ContentDialog ^ dialog = ref new Windows::UI::Xaml::Controls::ContentDialog(); | ||
| dialog->Content = Utils::StringPrintf(ex.what()); | ||
| dialog->CloseButtonText = L"OK"; | ||
| dialog->ShowAsync(); | ||
| } catch (const std::string &string) { | ||
| Windows::UI::Xaml::Controls::ContentDialog ^ dialog = ref new Windows::UI::Xaml::Controls::ContentDialog(); | ||
| dialog->Content = Utils::StringPrintf(string.c_str()); | ||
| dialog->CloseButtonText = L"OK"; | ||
| dialog->ShowAsync(); | ||
| } catch (Platform::Exception ^ e) { | ||
| Windows::UI::Xaml::Controls::ContentDialog ^ dialog = ref new Windows::UI::Xaml::Controls::ContentDialog(); | ||
| Platform::String ^ errorMsg = ref new Platform::String(); | ||
| errorMsg = errorMsg->Concat(L"Exception: ", e->Message); | ||
| errorMsg = errorMsg->Concat(errorMsg, Utils::StringPrintf("%x", e->HResult)); | ||
| dialog->Content = errorMsg; | ||
| dialog->CloseButtonText = L"OK"; | ||
| dialog->ShowAsync(); | ||
| } catch (...) { | ||
| Windows::UI::Xaml::Controls::ContentDialog ^ dialog = ref new Windows::UI::Xaml::Controls::ContentDialog(); | ||
| dialog->Content = L"Generic Exception"; | ||
| dialog->CloseButtonText = L"OK"; | ||
| dialog->ShowAsync(); | ||
| } | ||
| })); | ||
| that->m_main->CreateDeviceDependentResources(); | ||
| that->m_main->CreateWindowSizeDependentResources(); | ||
| that->m_main->StartRenderLoop(); | ||
| } catch (const std::exception &ex) { | ||
| Utils::Logf("StreamPage::Page_Loaded: Exception when starting stream. Exception: %s", ex.what()); | ||
| } catch (const std::string &string) { | ||
| Utils::Logf("StreamPage::Page_Loaded: Exception when starting stream. Exception: %s", string); | ||
| } catch (Platform::Exception ^ e) { | ||
| Platform::String ^ errorMsg = ref new Platform::String(); | ||
| errorMsg = errorMsg->Concat(L"Exception: ", e->Message); | ||
| errorMsg = errorMsg->Concat(errorMsg, Utils::StringPrintf("%x", e->HResult)); | ||
| Utils::Logf("StreamPage::Page_Loaded: Exception when starting stream. Exception: %s", Utils::PlatformStringToStdString(errorMsg)); | ||
| } catch (...) { | ||
| Utils::Log("StreamPage::Page_Loaded: Exception when starting stream. Exception: Generic Exception"); | ||
| } | ||
| }); | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| } | ||
|
|
||
| void StreamPage::Page_Unloaded(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e) { | ||
|
|
@@ -127,11 +105,13 @@ void StreamPage::Page_Unloaded(Platform::Object ^ sender, Windows::UI::Xaml::Rou | |
|
|
||
| try { | ||
| this->m_main->StopRenderLoop(); | ||
| this->m_main.reset(); | ||
| } catch (std::exception &ex) { | ||
| Utils::Logf("StreamPage::Page_Unloaded m_main threw an exception: %s\n", ex.what()); | ||
| } catch (...) { | ||
| Utils::Log("StreamPage::Page_Unloaded StopRenderLoop threw an exception\n"); | ||
| Utils::Log("StreamPage::Page_Unloaded m_main threw an exception\n"); | ||
| } | ||
|
|
||
| this->m_main.reset(); | ||
| Utils::Log("StreamPage::Page_Unloaded m_main reset\n"); | ||
|
Comment on lines
106
to
115
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
If Proposed fix try {
this->m_main->StopRenderLoop();
- this->m_main.reset();
} catch (std::exception &ex) {
Utils::Logf("StreamPage::Page_Unloaded m_main threw an exception: %s\n", ex.what());
} catch (...) {
Utils::Log("StreamPage::Page_Unloaded m_main threw an exception\n");
}
+
+ this->m_main.reset();
Utils::Log("StreamPage::Page_Unloaded m_main reset\n");🤖 Prompt for AI Agents |
||
| } | ||
|
|
||
|
|
@@ -273,7 +253,7 @@ void StreamPage::disconnectAndCloseButton_Click(Platform::Object ^ sender, Windo | |
| // UI is sent back to HostSelectorPage in StartRenderLoop(), after the loop exits | ||
| // All we need to do is close the progress dialog | ||
|
|
||
| DISPATCH_UI([progressToken], { | ||
| DISPATCH_UI([progressToken] { | ||
| ::moonlight_xbox_dx::ModalDialog::HideDialogByToken(progressToken); | ||
| }); | ||
| } catch (...) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -289,9 +289,17 @@ int MoonlightClient::StartStreaming(std::shared_ptr<DX::DeviceResources> res, St | |
| char message[2048]; | ||
| sprintf(message, "gs_startapp failed with status code %d\n", a); | ||
| Utils::Log(message); | ||
| Utils::Log(gs_error); | ||
|
|
||
| if (gs_error) { | ||
| char errorMessage[2048]; | ||
| sprintf(errorMessage, "%s\n", gs_error); | ||
|
|
||
| Utils::Log(errorMessage); | ||
| this->OnFailed(0, a, errorMessage); | ||
| } | ||
| return a; | ||
| } | ||
|
|
||
| // Sleep(10000); | ||
| connectedInstance = this; | ||
| CONNECTION_LISTENER_CALLBACKS callbacks; | ||
|
|
@@ -311,10 +319,17 @@ int MoonlightClient::StartStreaming(std::shared_ptr<DX::DeviceResources> res, St | |
| DECODER_RENDERER_CALLBACKS rCallbacks = FFMpegDecoder::getDecoder(); | ||
|
|
||
| AUDIO_RENDERER_CALLBACKS aCallbacks = AudioPlayer::getDecoder(); | ||
|
|
||
| int k = LiStartConnection(&serverData.serverInfo, &config, &callbacks, &rCallbacks, &aCallbacks, NULL, 0, NULL, 0); | ||
|
|
||
| sprintf(message, "LiStartConnection %d\n", k); | ||
| Utils::Log(message); | ||
| return k; | ||
|
|
||
| if (k != 0) { | ||
| this->OnFailed(0, k, "Connection failed"); | ||
| } | ||
|
|
||
| return k; | ||
| } | ||
|
|
||
| void MoonlightClient::StopStreaming() { | ||
|
|
@@ -326,6 +341,16 @@ void log_message(const char *fmt, ...) { | |
| va_start(argp, fmt); | ||
| char message[2048]; | ||
| vsprintf_s(message, fmt, argp); | ||
|
|
||
| // Append a single '\n' only if the string doesn't already end with one. | ||
| size_t len = strlen(message); | ||
| if (len == 0 || message[len - 1] != '\n') { | ||
| if (len + 1 < sizeof(message)) { | ||
| message[len] = '\n'; | ||
| message[len + 1] = '\0'; | ||
| } | ||
| } | ||
|
|
||
| Utils::Log(message); | ||
| } | ||
|
|
||
|
|
@@ -340,13 +365,14 @@ void connection_started() { | |
|
|
||
| void connection_status_update(int status) { | ||
| char message[4096]; | ||
| sprintf(message, "Stage %d started\n", status); | ||
| auto stageName = LiGetFormattedStageName(status); | ||
| sprintf(message, "Stage %d: '%s' - Started\n", status, LiGetFormattedStageName(status)); | ||
| Utils::Log(message); | ||
| } | ||
|
Comment on lines
366
to
371
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same nullptr risk in
Proposed fix- auto stageName = LiGetFormattedStageName(status);
- sprintf(message, "Stage %d: '%s' - Started\n", status, LiGetFormattedStageName(status));
+ const char* stageName = LiGetFormattedStageName(status);
+ sprintf(message, "Stage %d: '%s' - Started\n", status, stageName ? stageName : "Unknown");🤖 Prompt for AI Agents |
||
|
|
||
| void connection_status_completed(int status) { | ||
| char message[4096]; | ||
| sprintf(message, "Stage %d completed\n", status); | ||
| sprintf(message, "Stage %d: '%s' - Completed\n", status, LiGetFormattedStageName(status)); | ||
| Utils::Log(message); | ||
|
Comment on lines
373
to
376
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same nullptr risk in Proposed fix- sprintf(message, "Stage %d: '%s' - Completed\n", status, LiGetFormattedStageName(status));
+ const char* stageName = LiGetFormattedStageName(status);
+ sprintf(message, "Stage %d: '%s' - Completed\n", status, stageName ? stageName : "Unknown");🤖 Prompt for AI Agents |
||
| if (connectedInstance->OnStatusUpdate != nullptr) { | ||
| connectedInstance->OnStatusUpdate(status); | ||
|
|
@@ -370,10 +396,10 @@ void connection_terminated(int status) { | |
| void stage_failed(int stage, int err) { | ||
| char message[4096]; | ||
| unsigned int portFlags = LiGetPortFlagsFromStage(stage); | ||
| int portResult = LiTestClientConnectivity("qt.conntest.moonlight-stream.org", 443, portFlags); | ||
| // int portResult = LiTestClientConnectivity("qt.conntest.moonlight-stream.org", 443, portFlags); | ||
| char failingPorts[128]; | ||
| LiStringifyPortFlags(portFlags, ", ", failingPorts, sizeof(failingPorts)); | ||
| sprintf(message, "%s failed with error %d.\n Check Firewall and Connections to port: %s\n", LiGetStageName(stage), err, failingPorts); | ||
| sprintf(message, "Stage %d: '%s' - Failed with error: %d.\n", stage, LiGetFormattedStageName(stage), err, failingPorts); | ||
| Utils::Log(message); | ||
| if (connectedInstance->OnFailed != nullptr) { | ||
| connectedInstance->OnFailed(stage, err, message); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Snuck this in. Removed the WoL Success dialog. This just feels silly to have now that we have a visual polling feedback.