uwp: fix crash when opening menu/canceling load. CI job

This commit is contained in:
flyinghead 2021-11-20 16:18:27 +01:00
parent 501244ed25
commit bc34024e32
12 changed files with 152 additions and 12 deletions

48
.github/workflows/uwp.yml vendored Normal file
View File

@ -0,0 +1,48 @@
name: Windows UWP CI
on: [push, pull_request]
jobs:
build:
runs-on: windows-latest
env:
VCPKG_ROOT: ${{ github.workspace }}/vcpkg
steps:
- uses: actions/cache@v2
id: cache
with:
path: $HOME/ccache
key: ccache-${{ github.sha }}
restore-keys: ccache-
- uses: actions/checkout@v2
with:
fetch-depth: 0
submodules: true
- name: bootstrap vcpkg
run: |
git clone https://github.com/microsoft/vcpkg
vcpkg/bootstrap-vcpkg.bat
- name: CMake
run: |
cmake -B build -DCMAKE_BUILD_TYPE=Release -G "Visual Studio 16 2019" -A x64 -DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION="10.0" -DCMAKE_SYSTEM_PROCESSOR=AMD64 -DCMAKE_CROSSCOMPILING=OFF -DUSE_VULKAN=OFF -DUSE_GLES=ON -DCMAKE_TOOLCHAIN_FILE=%VCPKG_DIR%\scripts\buildsystems\vcpkg.cmake
cmake --build build --config Release --parallel 2
shell: cmd
- name: Package app
run: |
mkdir build\artifact
cd build\AppPackages\flycast\flycast_1.0.0.0_x64_Test
mkdir tmp
makeappx.exe unpack /v /p .\flycast_1.0.0.0_x64.msix /d tmp
copy ..\..\..\Release\*.dll tmp
makeappx pack /d tmp /p ..\..\..\artifact\flycast.appx
- uses: actions/upload-artifact@v2
with:
name: flycast-uwp
path: build/artifact

View File

@ -1359,6 +1359,7 @@ if(NOT LIBRETRO)
shell/uwp/flycast150.png
shell/uwp/flycast50.png
shell/uwp/flycast44.png
shell/uwp/splash.png
shell/uwp/flycast44.targetsize-48_altform-unplated.png
shell/uwp/flycast44.targetsize-48_altform-lightunplated.png
core/deps/SDL/src/main/winrt/SDL2-WinRTResource_BlankCursor.cur

View File

@ -25,7 +25,7 @@
#endif
#if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP)
#define TARGET_UWP 1
#define TARGET_UWP
#endif
/*

View File

@ -35,7 +35,11 @@ if (NOT WIN32)
target_compile_definitions(miniupnpc-private INTERFACE _XOPEN_SOURCE=600)
endif ()
else ()
target_compile_definitions(miniupnpc-private INTERFACE _WIN32_WINNT=0x0501) # XP or higher for getnameinfo and friends
if (WINDOWS_STORE)
target_compile_definitions(miniupnpc-private INTERFACE _WIN32_WINNT=0x0A00 _WINSOCK_DEPRECATED_NO_WARNINGS)
else ()
target_compile_definitions(miniupnpc-private INTERFACE _WIN32_WINNT=0x0501) # XP or higher for getnameinfo and friends
endif ()
endif ()
if (CMAKE_SYSTEM_NAME STREQUAL "Darwin")

View File

@ -1,10 +1,10 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9842447..f1b3c43 100644
index 06bc77c..9ac12fc 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -12,8 +12,8 @@ option(INSTALL_STATIC_LIBS "Install static libraries" OFF)
option(WITH_SYSTEM_ZLIB "Use system provided zlib library" OFF)
if(CMAKE_C_COMPILER_ID MATCHES "GNU")
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden -fPIC -O3 -flto")
- set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON)
@ -13,3 +13,37 @@ index 9842447..f1b3c43 100644
elseif(CMAKE_C_COMPILER_ID MATCHES "Clang")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3")
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION OFF)
@@ -34,7 +34,11 @@ add_subdirectory(deps/lzma-19.00 EXCLUDE_FROM_ALL)
# zlib
if (WITH_SYSTEM_ZLIB)
- pkg_check_modules(ZLIB REQUIRED zlib)
+ if (WINDOWS_STORE)
+ find_package(ZLIB REQUIRED)
+ else()
+ pkg_check_modules(ZLIB REQUIRED zlib)
+ endif()
list(APPEND PLATFORM_INCLUDES ${ZLIB_INCLUDE_DIRS})
list(APPEND PLATFORM_LIBS ${ZLIB_LIBRARIES})
else()
@@ -68,6 +72,10 @@ if (INSTALL_STATIC_LIBS)
)
endif()
+if(MSVC)
+ target_compile_definitions(chdr-static PRIVATE _CRT_SECURE_NO_WARNINGS)
+endif()
+
if (BUILD_SHARED_LIBS)
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
@@ -79,7 +87,7 @@ if (BUILD_SHARED_LIBS)
if(MSVC)
target_compile_definitions(chdr PUBLIC "CHD_DLL")
- target_compile_definitions(chdr PRIVATE "CHD_DLL_EXPORTS")
+ target_compile_definitions(chdr PRIVATE "CHD_DLL_EXPORTS" _CRT_SECURE_NO_WARNINGS)
elseif(APPLE)
target_link_options(chdr PRIVATE -Wl,-dead_strip -Wl,-exported_symbol,_chd_*)
else()

View File

@ -1,9 +1,11 @@
#ifndef PICO_SUPPORT_MSVC
#define PICO_SUPPORT_MSVC
#pragma pack(push, 8)
#include <stdio.h>
#include <time.h>
#include <windows.h>
#pragma pack(pop)
#if defined(_MSC_VER) || defined(_MSC_EXTENSIONS)
#define DELTA_EPOCH_IN_MICROSECS 11644473600000000Ui64

View File

@ -62,6 +62,8 @@ typedef SOCKET sock_t;
#define L_EAGAIN WSAEWOULDBLOCK
#define get_last_error() (WSAGetLastError())
#define perror(s) do { INFO_LOG(MODEM, "%s: Winsock error: %d\n", (s) != NULL ? (s) : "", WSAGetLastError()); } while (false)
#define SHUT_WR SD_SEND
#define SHUT_RD SD_RECEIVE
#endif
bool is_local_address(u32 addr);

View File

@ -401,7 +401,17 @@ void gui_open_settings()
{
gui_state = GuiState::Commands;
HideOSD();
emu.stop();
#ifdef TARGET_UWP
if (config::ThreadedRendering)
{
static std::future<void> f;
f = std::async(std::launch::async, [] {
emu.stop();
});
}
else
#endif
emu.stop();
}
else
chat.toggle();
@ -413,7 +423,6 @@ void gui_open_settings()
else if (gui_state == GuiState::Loading)
{
gameLoader.cancel();
gui_state = GuiState::Main;
}
else if (gui_state == GuiState::Commands)
{
@ -2258,12 +2267,25 @@ static void gui_network_start()
if (ImGui::Button("Cancel", ImVec2(100.f * scaling, 0.f)))
{
NetworkHandshake::instance->stop();
#ifdef TARGET_UWP
static std::future<void> f;
f = std::async(std::launch::async, [] {
try {
networkStatus.get();
}
catch (const FlycastException& e) {
}
emu.unloadGame();
gui_state = GuiState::Main;
});
#else
try {
networkStatus.get();
} catch (const FlycastException& e) {
}
gui_state = GuiState::Main;
emu.unloadGame();
#endif
}
ImGui::PopStyleVar();
@ -2311,10 +2333,7 @@ static void gui_display_loadscreen()
ImGui::SetCursorPosX((currentwidth - 100.f * scaling) / 2.f + ImGui::GetStyle().WindowPadding.x);
ImGui::SetCursorPosY(126.f * scaling);
if (ImGui::Button("Cancel", ImVec2(100.f * scaling, 0.f)))
{
gameLoader.cancel();
gui_state = GuiState::Main;
}
}
} catch (const FlycastException& ex) {
ERROR_LOG(BOOT, "%s", ex.what());

View File

@ -80,12 +80,32 @@ public:
void cancel()
{
progress.cancelled = true;
#ifdef TARGET_UWP
if (future.valid())
{
if (progress.cancelled)
return;
static std::future<void> f;
f = std::async(std::launch::async, [this] {
try {
future.get();
}
catch (const FlycastException& e) {
}
emu.unloadGame();
gui_state = GuiState::Main;
});
return
}
#else
if (future.valid())
try {
future.get();
} catch (const FlycastException& e) {
}
#endif
emu.unloadGame();
gui_state = GuiState::Main;
}
bool ready()

View File

@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Package
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest"
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
IgnorableNamespaces="uap mp">
<Identity Name="AF75D068-D5AC-3D3C-B52A-2791C2F3491A" Publisher="CN=CMake" Version="1.0.0.0" />
<Identity Name="AF75D068-D5AC-3D3C-B52A-2791C2F3491A" Publisher="CN=Flyinghead, O=Flycast, C=US" Version="1.0.0.0" />
<mp:PhoneIdentity PhoneProductId="AF75D068-D5AC-3D3C-B52A-2791C2F3491A" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>
<Properties>
<DisplayName>Flycast</DisplayName>
@ -25,11 +25,12 @@
BackgroundColor="transparent"
Square150x150Logo="flycast150.png"
Square44x44Logo="flycast44.png">
<!-- uap:SplashScreen Image="flycast.png" / -->
<uap:SplashScreen Image="splash.png" BackgroundColor="#000000"/>
<uap:InitialRotationPreference>
<uap:Rotation Preference="landscape" />
<uap:Rotation Preference="landscapeFlipped"/>
</uap:InitialRotationPreference>
<uap:DefaultTile/>
</uap:VisualElements>
</Application>
</Applications>

BIN
shell/uwp/splash.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

9
vcpkg.json Normal file
View File

@ -0,0 +1,9 @@
{
"name": "flycast",
"version-string": "1.2.0-dev",
"dependencies": [
"angle",
"sdl2",
"zlib"
]
}