Skip to content

Commit

Permalink
Merge branch 'unoplatform:master' into platform-runtime-helper
Browse files Browse the repository at this point in the history
  • Loading branch information
mcNets authored Dec 4, 2024
2 parents 46a9f73 + 2f3ac18 commit e304301
Show file tree
Hide file tree
Showing 305 changed files with 6,079 additions and 4,466 deletions.
39 changes: 32 additions & 7 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
matrix:
include:
- language: csharp
build-mode: none
build-mode: manual
- language: java-kotlin
build-mode: none # This mode only analyzes Java. Set this to 'autobuild' or 'manual' to analyze Kotlin too.
- language: javascript-typescript
Expand All @@ -61,6 +61,35 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4

- name: Free Disk Space (Ubuntu)
if: runner.os == 'Linux'
uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be #v1.3.1
with:
# this might remove tools that are actually needed,
# if set to "true" but frees about 6 GB
tool-cache: false

# all of these default to true, but feel free to set to
# "false" if necessary for your workflow
android: true
dotnet: true
haskell: true
large-packages: true
docker-images: true
swap-storage: true

- name: Pin .NET Version
run: |
cp build/ci/net9/global.json global.json
- name: Setup .NET SDK
uses: actions/setup-dotnet@3447fd6a9f9e57506b15f895c5b76d3b197dc7c2 # v3
with:
global-json-file: global.json
env:
DOTNET_INSTALL_DIR: ${{ runner.temp }}/.dotnet
DOTNET_ROOT: ${{ runner.temp }}/.dotnet

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
Expand All @@ -83,12 +112,8 @@ jobs:
- if: matrix.build-mode == 'manual'
shell: bash
run: |
echo 'If you are using a "manual" build mode for one or more of the' \
'languages you are analyzing, replace this with the commands to build' \
'your code, for example:'
echo ' make bootstrap'
echo ' make release'
exit 1
cd src/SamplesApp/SamplesApp.Skia.Generic
dotnet build SamplesApp.Skia.Generic.csproj -f net9.0 -c Release -p:UnoTargetFrameworkOverride=net9.0 /bl:ios-netcoremobile-sampleapp.binlog
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
Expand Down
2 changes: 1 addition & 1 deletion build/ci/.azure-devops-wasm-uitests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
- task: CopyFiles@2
displayName: 'Publish Wasm Site (net9.0)'
inputs:
SourceFolder: $(build.sourcesdirectory)/src/SamplesApp/SamplesApp.Wasm/bin/Release/net9.0/browser-wasm/publish/wwwroot
SourceFolder: $(build.sourcesdirectory)/src/SamplesApp/SamplesApp.Wasm/bin/Release/net9.0/publish/wwwroot
Contents: '**/*.*'
TargetFolder: $(build.artifactstagingdirectory)/site-net9.0-$(XAML_FLAVOR_BUILD)
CleanTargetFolder: false
Expand Down
14 changes: 13 additions & 1 deletion build/test-scripts/run-net7-template-linux.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,10 @@ $projects =
@(3, "5.3/uno53net9blank/uno53net9blank/uno53net9blank.csproj", @(), @()),

# 5.3 lib
@(3, "5.3/uno53net9Lib/uno53net9Lib.csproj", @(), @())
@(3, "5.3/uno53net9Lib/uno53net9Lib.csproj", @(), @()),

# 5.3 Uno App with Library reference
@(3, "5.3/uno53AppWithLib/uno53AppWithLib/uno53AppWithLib.csproj", @(), @()),

# 5.3 blank publish testing
# Disabled for LXD setup issues
Expand All @@ -91,10 +94,19 @@ $projects =
##
## When adding new template versions, create them in a separate version named folder
## using all the specific features that can be impacted by the use of the Uno.SDK

# Empty marker to allow new tests lines to end with a comma
@()
);

for($i = 0; $i -lt $projects.Length; $i++)
{
# Skip the end marker to help for new tests authoring
if ($projects[$i].Length -eq 0)
{
continue
}

$projectTestGroup=$projects[$i][0];
$projectPath=$projects[$i][1];
$projectParameters=$projects[$i][2];
Expand Down
17 changes: 17 additions & 0 deletions build/test-scripts/run-netcore-mobile-template-tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -350,14 +350,31 @@ $projects =
# Ensure that build can happen even if a RID is specified
@(4, "5.3/uno53net9blank/uno53net9blank/uno53net9blank.csproj", @("-f", "net9.0-android", "-r", "android-arm64"), @("macOS", "NetCore"))

# Ensure that build can happen even if a RID is specified
@(4, "5.3/uno53AppWithLib/uno53AppWithLib/uno53AppWithLib.csproj", @("-f", "net9.0"), @("macOS", "NetCore")),
@(4, "5.3/uno53AppWithLib/uno53AppWithLib/uno53AppWithLib.csproj", @("-f", "net9.0-browserwasm"), @("macOS", "NetCore")),
@(4, "5.3/uno53AppWithLib/uno53AppWithLib/uno53AppWithLib.csproj", @("-f", "net9.0-ios"), @("macOS", "NetCore")),
@(4, "5.3/uno53AppWithLib/uno53AppWithLib/uno53AppWithLib.csproj", @("-f", "net9.0-android"), @("macOS", "NetCore")),
@(4, "5.3/uno53AppWithLib/uno53AppWithLib/uno53AppWithLib.csproj", @("-f", "net9.0-maccatalyst"), @("macOS", "NetCore")),
@(4, "5.3/uno53AppWithLib/uno53AppWithLib/uno53AppWithLib.csproj", @("-f", "net9.0-desktop"), @("macOS", "NetCore")),

## Note for contributors
##
## When adding new template versions, create them in a separate version named folder
## using all the specific features that can be impacted by the use of the Uno.SDK

# Empty marker to allow new tests lines to end with a comma
@()
);

for($i = 0; $i -lt $projects.Length; $i++)
{
# Skip the end marker to help for new tests authoring
if ($projects[$i].Length -eq 0)
{
continue
}

$projectTestGroup=$projects[$i][0];
$projectPath=$projects[$i][1];
$projectOptions=$projects[$i][2];
Expand Down
14 changes: 13 additions & 1 deletion doc/articles/controls/Frame.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,16 @@ uid: Uno.Controls.Frame

## Using Frame with Uno

To improve performance during navigation, `Frame` on Android, iOS, and WebAssembly targets operates in different way than in WinUI. Whereas WinUI follows `NavigationCacheMode` property on individual `Page` instances, on iOS and Android we keep the individual page instances in the back stack in memory by default. This way the can be quickly surfaced back to the user during back navigation. This behavior can be controlled using the `FeatureConfiguration.Frame.UseWinUIBehavior` property. This defaults to `true` on Skia targets and to `false` on Android, iOS and WebAssembly.
To improve performance during navigation, `Frame` on Android, iOS, and WebAssembly targets operates in different way than in WinUI. Whereas WinUI follows `NavigationCacheMode` property on individual `Page` instances, on iOS and Android we keep the individual page instances in the back stack in memory by default. This way they can be quickly surfaced back to the user during back navigation. This behavior can be controlled using the `FeatureConfiguration.Frame.UseWinUIBehavior` property. This defaults to `true` on Skia targets and to `false` on Android, iOS and WebAssembly.

If you set `UseWinUIBehavior` to `true` on Android and iOS, you also need to override the default style for the control. You can do this by explicitly setting the `Style` to `XamlDefaultFrame`:

```xml
<Frame Style="{StaticResource XamlDefaultFrame}" />
```

Or by creating an implicit style based on `XamlDefaultFrame`:

```xml
<Style TargetType="Frame" BasedOn="XamlDefaultFrame" />
```
8 changes: 6 additions & 2 deletions doc/articles/controls/GLCanvasElement.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ uid: Uno.Controls.GLCanvasElement
---

> [!IMPORTANT]
> This functionality is only available on WinAppSDK and Skia Desktop (`netX.0-desktop`) targets that are running on platforms with support for hardware acceleration. On Windows and Linux, OpenGL is used directly and on macOS, Metal is used through the [ANGLE](https://en.wikipedia.org/wiki/ANGLE_(software)) library.
> This functionality is only available on WinAppSDK and Skia Desktop (`netX.0-desktop`) targets that are running on platforms with support for hardware acceleration. On Windows and Linux, OpenGL 3.0+ is used directly and on macOS, Metal is used through the [ANGLE](https://en.wikipedia.org/wiki/ANGLE_(software)) library.
`GLCanvasElement` is a control for drawing 3D graphics with OpenGL. It can be enabled by adding the [`GLCanvas` UnoFeature](xref:Uno.Features.Uno.Sdk). The OpenGL APIs provided are provided by [Silk.NET](https://dotnet.github.io/Silk.NET/).

Expand All @@ -23,7 +23,7 @@ These three abstract methods take a `Silk.NET.OpenGL.GL` parameter that can be u

### The GLCanvasElement constructor

The protected constructor requires a `Func<Window>` argument that fetches the `Microsoft.UI.Xaml.Window` object that the `GLCanvasElement` belongs to. This function is required because WinUI doesn't yet provide a way to get the `Window` of a `FrameworkElement`. This parameter is ignored on Uno Platform and must be set to null. This function is only called while the `GLCanvasElement` is still in the visual tree.
The protected constructor requires a `Func<Window>` argument that fetches the `Microsoft.UI.Xaml.Window` object that the `GLCanvasElement` belongs to. This function is required because WinUI doesn't yet provide a way to get the `Window` of a `FrameworkElement`. This parameter is ignored on Uno Platform and can be set to null. This function is only called while the `GLCanvasElement` is still in the visual tree.

### The `Init` method

Expand All @@ -41,6 +41,10 @@ On MacOS, since OpenGL support is not natively present, we use [ANGLE](https://e

Additionally, `GLCanvasElement` has an `Invalidate` method that requests a redrawing of the `GLCanvasElement`, calling `RenderOverride` in the process. Note that `RenderOverride` will only be called once per `Invalidate` call and the output will be saved to be used in future frames. To update the output, you must call `Invalidate`. If you need to continuously update the output (e.g. in an animation), you can add an `Invalidate` call inside `RenderOverride`.

## Detecting errors

To detect errors in initializing the OpenGL environment, `GLCanvasElement` exposes an `IsGLInitializedProperty` dependency property that shows whether or nor the loading of the element and its OpenGL setup were successful. This property is only valid when the element is loaded, i.e. its `IsLoaded` property is true. When the element is not loaded, the value of `IsGLInitialized` will be null. `GLCanvasElement` implements `INotifyPropertyChanged`, so you can use this property in a data bindings, for example to set the visibility of a control as a fallback. Attempting to change this property is illegal.

## How to use Silk.NET

To learn more about using [Silk.NET](https://www.nuget.org/packages/Silk.NET.OpenGL/) as a C# binding for OpenGL, see the examples in the Silk.NET repository [here](https://github.com/dotnet/Silk.NET/tree/main/examples/CSharp). Note that the windowing and inputs APIs in Silk.NET are not relevant to `GLCanvasElement`, since we only use Silk.NET as an OpenGL binding library, not a windowing library.
Expand Down
14 changes: 14 additions & 0 deletions doc/articles/features/using-the-uno-sdk.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,20 @@ By Default when using the Uno.Sdk you get the added benefit of default includes

As discussed above setting `EnableDefaultUnoItems` to false will disable these includes.

> [!TIP]
> When you need to exclude specific files from a particular target framework (such as WebAssembly), you can use a custom MSBuild target:
>
> ```xml
> <Target Name="AdjustAppItemGroups" BeforeTargets="ResolveAssemblyReferences">
> <ItemGroup Condition="'$(TargetFramework)' == 'net9.0-browserwasm'">
> <None Remove="Page.xaml"/>
> <Page Remove="Page.xaml"/>
> </ItemGroup>
> </Target>
> ```
>
> This approach allows you to selectively remove pages from specific target frameworks while maintaining them in others.
## Apple Privacy Manifest Support
Starting May 1st, 2024, Apple requires the inclusion of a new file, the [Privacy Manifest file](https://developer.apple.com/documentation/bundleresources/privacy_manifest_files) (named `PrivacyInfo.xcprivacy`), in app bundles. This file is crucial for complying with updated privacy regulations.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ For Android, there is one permission you must configure before using this API in
- The `Cancel` method is not supported.
- The parameter of the `Vibrate(TimeSpan)` method is not taken into account - iOS supports only a default vibration duration.

#### WinUI

- The `Windows.Phone.Devices.Notification` namespace is no longer supported in WinUI.
- Developers should use the [Windows.Devices.Haptics](xref:Uno.Features.WDHaptics) namespace for vibration functionality.

#### UWP

- The `VibrationDevice` class is only available in the UWP-head if the `Windows.Mobile.Extensions for the UWP` is added to the project.
7 changes: 6 additions & 1 deletion doc/articles/guides/profiling-applications.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Run the following commands

- `dotnet tool update -g dotnet-dsrouter`
- `dotnet tool update -g dotnet-trace`
- `dotnet tool update -g dotnet-gcdump`

## Profiling .NET iOS applications

Expand Down Expand Up @@ -164,7 +165,11 @@ The `suspend` directive means that the application will wait for `dotnet-trace`

- Open a browser at `https://speedscope.app` and drop the `*.speedscope.json` file in it

See complete [documentation](https://github.com/xamarin/xamarin-android/blob/main/Documentation/guides/tracing.md) for more details.
### Getting GC memory dumps

To take a GC memory dump of a running android app, follow the same steps above, but instead of `dotnet-trace collect -p <port>`, use `dotnet-gcdump collect -p <port>`. It will create a `.gcdump` file that can be viewed in Visual Studio and Perfview on Windows and [heapview](https://github.com/1hub/dotnet-heapview) on non-Windows platforms.

See complete [documentation](https://github.com/dotnet/android/blob/main/Documentation/guides/tracing.md) for more details.

### Analyzing the trace data

Expand Down
33 changes: 21 additions & 12 deletions doc/articles/uno-development/Internal-WeakEventHelper.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ The WeakEventHelper class is an internal method that is designed to provide a
memory-friendly environment for registering to events internally in Uno.

This class is not exposed to the end-user because its patterns do not fit with the
original UWP event-based designs of the API.
original WinUI event-based designs of the API.

## The RegisterEvent method

Expand All @@ -17,35 +17,44 @@ that both the source and the target are weak. The source must be kept alive by
another longer-lived reference, and the target is kept alive by the
return disposable.

If the returned disposable is collected, the handler will also be
collected. Conversely, if the provided list is collected
raising the event will produce nothing.
If the provided handler is collected, the registration will
be collected as well. The returned disposable is not tracked, which means that it will
not remove the registration when collected, unless the provided handler is a lambda. In
this case, the lambda's lifetime is tied to the returned disposable.

The WeakEventCollection automatically manages its internal registration list using GC events.

Here's a usage example:

private List<WeakEventHelper.GenericEventHandler> _sizeChangedHandlers = new List<WeakEventHelper.GenericEventHandler>();
```csharp
private WeakEventHelper.WeakEventCollection? _sizeChangedHandlers;

internal IDisposable RegisterSizeChangedEvent(WindowSizeChangedEventHandler handler)
{
return WeakEventHelper.RegisterEvent(
_sizeChangedHandlers,
_sizeChangedHandlers ??= new(),
handler,
(h, s, e) => (h as WindowSizeChangedEventHandler)?.Invoke(s, (WindowSizeChangedEventArgs)e)
);
}

internal void RaiseEvent()
{
_sizeChangedHandlers?.Invoke(this, new WindowSizeChangedEventArgs());
}
```

The RegisterEvent method is intentionally non-generic to avoid the cost related to AOT performance. The
performance cost is shifted to downcast and upcast checks in the `EventRaiseHandler` handlers.

The returned disposable must be used as follows :

private SerialDisposable _sizeChangedSubscription = new SerialDisposable();
```csharp
private IDisposable? _sizeChangedSubscription;

...

_sizeChangedSubscription.Disposable = null;
_sizeChangedSubscription?.Dispose();

if (Owner != null)
{
_sizeChangedSubscription.Disposable = Window.Current.RegisterSizeChangedEvent(OnCurrentWindowSizeChanged);
}
_sizeChangedSubscription = Window.Current.RegisterSizeChangedEvent(OnCurrentWindowSizeChanged);
```
2 changes: 2 additions & 0 deletions doc/articles/uno-development/uno-internals-hotreload.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ Pausing and resuming UI Update is done by calling

Note that pausing UI Updates doesn't stop the Hot Reload process. It only prevents the UI Update from running until UI Updates are resumed.

<!---
## Waiting for Hot Reload to be applied
// TODO: Give an example of how to await UI Updates (eg https://github.com/unoplatform/uno/blob/0340cc1394994cdbd525d61de611a0531c38bcc7/src/Uno.UI.RuntimeTests/Tests/HotReload/Frame/HRApp/Tests/Given_Frame.cs#L9-L37)
-->
Binary file removed src/AddIns/Uno.WinUI.Graphics3DGL/Assets/error.png
Binary file not shown.
Loading

0 comments on commit e304301

Please sign in to comment.