Skip to content
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

Migrating to Windows App SDK (WinUI 3) #9

Closed
BestOwl opened this issue Mar 11, 2022 · 1 comment · Fixed by #12
Closed

Migrating to Windows App SDK (WinUI 3) #9

BestOwl opened this issue Mar 11, 2022 · 1 comment · Fixed by #12
Assignees
Milestone

Comments

@BestOwl
Copy link
Owner

BestOwl commented Mar 11, 2022

TL;DR

We are planning to refactor and migrate from UWP to Windows App SDK desktop app

Current Architecture

Currently, the main UI is a UWP app, which causes some trouble to implement the messaging feature.

Project Type Description
MyPhone.TrayApp.XamlHost C++ UWP Project XAML island host
MyPhone.TrayApp C++ Win32 Project Main app logic, system tray UI and UWP "broker". Enable the UWP app to call Win32 APIs and keeping the app running in the background. Use XAML island to make the system tray UI has the same look and feel as native UWP system apps. This project handles main app logic including Bluetooth HFP stuff.
MyPhone C# UWP Project Main app UI
PackageProject Desktop Bridge Packaging Project Generate MSIX app package

Problem: UWP background restriction.

In order to receive message notification from MCE (mobile phone), the MNS server needs to keep running in the background and keep connected to the MCE. Being a UWP app makes it "impossible" to do that because a UWP app cannot run in the background for a long time. A common method to bypass this restriction is to put the server in a Win32 broker process (like MyPhone.TrayApp) so that it can run in the background indefinitely, and then pass the message content to the UWP UI. But passing a huge amount of data between two processes may cause both development overhead and runtime performance overhead because you need to handle Inter-Process Communication (IPC).

Why we chose UWP?

We want to use the WinUI library to match the look and feel with the system. Back to the time when this project was started, there are only two ways to use WinUI.

  1. UWP
  2. XAML Island (Attach UWP UI in a Win32 process)

Although we can use XAML Island at that time, some important dev tools are missing (such as XAML hot reload, XAML designer, etc.). Thus UWP was the primary choice.

New Architecture

With the release of Windows App SDK 1.0, the use of UWP has become meaningless.

  1. The primary use case of this app is to use it on a desktop or laptop PC. Who would try to use this app on a Windows Phone to make phone calls via another phone's cellular network?
  2. Being a desktop app simplifies everything. No need to use "broker" anymore; no complicated IPC handling. We can keep everything in one single process.

Therefore, we are planning to migrate this project from UWP to Windows App SDK.

Project Type Description
MyPhone C# Windows App SDK Project Main UI, tray icon, background server, and everything else, all in one process
PackageProject Desktop Bridge Packaging Project Generate MSIX app package
@BestOwl
Copy link
Owner Author

BestOwl commented Mar 15, 2022

During the migration, I will also refactor view models using MVVM toolkit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant