dotnet / dotnet/maui

Big path images not loading on Android (infinity-loop, GC-free)

Open
#9,867 4 comments 0 reactions 0 assignees View on GitHub
area-controls-image area-single-project platform/android s/triaged s/verified t/bug
Dominant language
C#
Stars
23.3k
Forks
2k
Avg merge
1d 15h
Merged PRs (30d)
290

Description

### Description

When we convert our SVG images into paths resources (similar approach as DrawingImage in WPF) **we run into a infinity loop on app startup**.

Info: In our example we use about 30 path images (generated from SVG images via MS Blend into paths). This way scaling will work nicely and crisp for Mobile Phones and Tablets without creating big app size -> compared to MauiImage. In our case about 500 images and more are need to be available offline in the app.

Repo for reproduction: https://github.com/maexsp/MauiResources/tree/ResourcesLoadingIssue

### Steps to Reproduce

- Use Android emulator.
- Start the App (see reproduction repository).
- Infinity loop! (GC freed messages)

Comment out the Frame images from BigImagePath21 to BigImagePath30 and the app starts but very long app startup time

- With 20 images only the app will load on android but needs about 15 sec for startup
- WinUI: 30 images need about 40 sec to load
- Android: 30 images will not load on Android emulator and also not Android Samsung Galaxy S22
- iOS: not tested yet

When Frame images are commented out the app startup time is also very high. Probably also there is an issue.

Output (when using android emulator:

[name.mauiappre] Explicit concurrent copying GC freed 4(31KB) AllocSpace objects, 0(0B) LOS objects, 49% free, 15MB/30MB, paused 12us,12us total 24.487ms
[monodroid-gc] 46637 outstanding GREFs. Performing a full GC!
[name.mauiappre] Explicit concurrent copying GC freed 4(31KB) AllocSpace objects, 0(0B) LOS objects, 49% free, 15MB/30MB, paused 12us,11us total 24.501ms
[monodroid-gc] 46638 outstanding GREFs. Performing a full GC!
[name.mauiappre] Explicit concurrent copying GC freed 4(31KB) AllocSpace objects, 0(0B) LOS objects, 49% free, 15MB/30MB, paused 11us,11us total 25.450ms
[monodroid-gc] 46639 outstanding GREFs. Performing a full GC!
[name.mauiappre] Explicit concurrent copying GC freed 4(31KB) AllocSpace objects, 0(0B) LOS objects, 49% free, 15MB/30MB, paused 11us,11us total 24.772ms
[monodroid-gc] 46640 outstanding GREFs. Performing a full GC!

### Link to public reproduction project repository

https://github.com/maexsp/MauiResources/tree/ResourcesLoadingIssue

### Version with bug

6.0.486 (current)

### Last version that worked well

Unknown/Other

### Affected platforms

Android, Windows, I was *not* able test on other platforms

### Affected platform versions

Android 10, Android 12, Win10

### Did you find any workaround?

No workaround found. We cannot use MauiImages cause the App Size will than increased to much (over 100MB).

SkiaSharp we use right now but performance is very slow and not well maintained (old not maintained SVG parser from 2018).

### Relevant log output

```shell
.[name.mauiappre] Explicit concurrent copying GC freed 4(31KB) AllocSpace objects, 0(0B) LOS objects, 49% free, 15MB/30MB, paused 12us,12us total 24.487ms
[monodroid-gc] 46637 outstanding GREFs. Performing a full GC!
[name.mauiappre] Explicit concurrent copying GC freed 4(31KB) AllocSpace objects, 0(0B) LOS objects, 49% free, 15MB/30MB, paused 12us,11us total 24.501ms
[monodroid-gc] 46638 outstanding GREFs. Performing a full GC!
[name.mauiappre] Explicit concurrent copying GC freed 4(31KB) AllocSpace objects, 0(0B) LOS objects, 49% free, 15MB/30MB, paused 11us,11us total 25.450ms
[monodroid-gc] 46639 outstanding GREFs. Performing a full GC!
[name.mauiappre] Explicit concurrent copying GC freed 4(31KB) AllocSpace objects, 0(0B) LOS objects, 49% free, 15MB/30MB, paused 11us,11us total 24.772ms
[monodroid-gc] 46640 outstanding GREFs. Performing a full GC!
```

Contributor guide

Open the contributing guide

Research direction

Clone the linked MauiResources repository on the ResourcesLoadingIssue branch and reproduce startup with the BigImagePath21–BigImagePath30 Frame images on an Android emulator. Compare the 20-image and 30-image cases while watching the GC and outstanding GREF logs; done means the path resources load without an infinite loop and startup is no longer excessively slow on the affected platforms.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, csharp
Domain
desktop-dev, mobile-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.