• Stars
    star
    193
  • Rank 199,778 (Top 4 %)
  • Language
    C#
  • License
    MIT License
  • Created over 6 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

glidex.forms is a library using Glide for faster Xamarin.Forms images on Android. Find out more about Glide at https://github.com/bumptech/glide

glidex.forms (or just glidex)

Google recommends Glide for simplifying the complexity of managing Android.Graphics.Bitmap within your apps (docs here).

glidex.forms is small library we can use to improve Xamarin.Forms image performance on Android by taking a dependency on Glide. See my post on the topic here.

Download from NuGet:

glidex.forms
NuGet

Learn more on this episode of the Xamarin Show:

Super Fast Image Loading for Android Apps with GlideX | The Xamarin Show

If you have a "classic" Xamarin.Android app that is not Xamarin.Forms, it could be useful to use the Xamarin.Android.Glide NuGet package. If you want to improve the Xamarin binding for Glide, contribute to it on Github!

How do I use glidex.forms?

To set this library up in your existing project, merely:

  • Add the glidex.forms NuGet package
  • Add this one liner after your app's Forms.Init call:
Xamarin.Forms.Forms.Init (this, bundle);
//This forces the custom renderers to be used
Android.Glide.Forms.Init (this);
LoadApplication (new App ());

How do I know my app is using Glide?

On first use, you may want to enable debug logging:

Android.Glide.Forms.Init (this, debug: true);

glidex.forms will print out log messages in your device log as to what is happening under the hood.

If you want to customize how Glide is used in your app, currently your option is to implement your own IImageViewHandler. See the GlideExtensions class for details.

Comparing Performance

It turns out it is quite difficult to measure performance improvements specifically for images in Xamarin.Forms. Due to the asynchronous nature of how images load, I've yet to figure out good points at which to clock times via a Stopwatch.

So instead, I found it much easier to measure memory usage. I wrote a quick class that runs a timer and calls the Android APIs to grab memory usage.

Here is a table of peak memory used via the different sample pages I've written:

NOTE: this was a past comparison with Xamarin.Forms 2.5.x

Page Loaded by Peak Memory Usage
GridPage Xamarin.Forms 268,387,112
GridPage glidex.forms 16,484,584
ViewCellPage Xamarin.Forms 94,412,136
ViewCellPage glidex.forms 12,698,112
ImageCellPage Xamarin.Forms 24,413,600
ImageCellPage glidex.forms 9,977,272
HugeImagePage Xamarin.Forms 267,309,792
HugeImagePage glidex.forms 9,943,184

NOTE: I believe these numbers are in bytes. I restarted the app (release mode) before recording the numbers for each page. Pages with ListViews I scrolled up and down a few times.

Stock XF performance of images is poor due to the amount of Android.Graphics.Bitmap instances created on each page. Disabling the Glide library in the sample app causes "out of memory" errors to happen as images load. You will see empty white squares where this occurs and get console output.

To try stock Xamarin.Forms behavior yourself, you can remove the references to glidex and glidex.forms in the glide.forms.sample project and comment out the Android.Glide.Forms.Init() line.

Features

In my samples, I tested the following types of images:

  • ImageSource.FromFile with a temp file
  • ImageSource.FromFile with AndroidResource
  • ImageSource.FromResource with EmbeddedResource
  • ImageSource.FromUri with web URLs
  • ImageSource.FromStream with AndroidAsset

For example, the GridPage loads 400 images into a grid with a random combination of all of the above:

GridPage

More Repositories

1

dotnes

.NET for the NES game console
C#
617
star
2

spice

Spice 🌶, a spicy cross-platform UI framework!
C#
226
star
3

Xamarin.Forms.Mocks

Library for running Xamarin.Forms inside of unit tests
C#
195
star
4

Xamarin.Android.Lite

Prototype/proof of concept of a "lite" Xamarin.Android that only supports Xamarin.Forms
C#
124
star
5

boots

boots is a .NET global tool for "bootstrapping" vsix & pkg files. Just "boots https://url/to/your/package"!
C#
86
star
6

Android-NativeAOT

A .NET 8, NativeAOT example on Android
C#
66
star
7

maui-profiling

Repository for building MAUI apps over time. So we can install & profile them.
C#
57
star
8

XPlatUtils

A set of helpers for cross platform apps. Right now has a ServiceContainer and Messenger implementation.
C#
37
star
9

memory-analyzers

C# code analyzers for finding memory leaks
C#
35
star
10

Mono.Profiler.Android

Support for the Mono profiler in .NET 6 Android applications
Shell
33
star
11

inclusive-code-reviews-browser

A chrome web extension for improving code reviews on Github or Azure DevOps
JavaScript
31
star
12

Xamarin.InAppPurchasing

Sample project for secure in-app purchases with Xamarin for iOS and Google Play
C#
27
star
13

XamChat

Simple chat application for iOS and Android
C#
26
star
14

UnityBuild

Example project showing automated builds with Unity3D
C#
24
star
15

lols

Performance test: LOLs per second
C#
24
star
16

HelloGlide

A simple sample using glidex.forms
C#
15
star
17

inclusive-code-reviews-ml

Machine learning for code reviews!
C#
14
star
18

Xamarin.SSLPinning

Test project to setup SSL pinning with Xamarin.iOS
C#
14
star
19

Xamarin.Forms.Benchmarks

Using BenchmarkDotNet to write some benchmarks for Xamarin.Forms concepts.
C#
11
star
20

measure-startup

C# console app to launch a process, wait for stdout, report a time
C#
8
star
21

MemoryLeaksOniOS

Testing memory leaks on iOS
C#
6
star
22

maui-scrolling-performance

Test repository for measuring scrolling performance of .NET MAUI apps on Android
C#
5
star
23

maui-workload

Prototype of a dotnet/maui "workload"
PowerShell
3
star
24

wpf-memory-leaks

Unit tests using WPF, to discover if/how it avoids memory leaks
C#
3
star
25

android-profiled-aot

This is a repo for recording .NET 6 AOT profiles.
C#
3
star
26

MyPal

A .NET MAUI sample application that uses omni-input LLMs to create "My Pal", a friendly koala that insults you based on a selfie!
C#
3
star
27

MonoGameSaveImage

Example of using Texture2D.SaveAsPng and Texture2D.SaveAsPng
C#
2
star
28

Benchmarks

Group of C# benchmarks for testing purposes
C#
2
star
29

baseline-profiles

For recording baseline profiles, see: https://developer.android.com/topic/performance/baselineprofiles
Java
2
star
30

CustomResourceDesigner

Example of making a "slimmer" Resource.designer.cs
C#
2
star
31

BenchmarkDotNet-Android

BenchmarkDotNet projects for comparing .NET 6 to Xamarin.Android
C#
2
star
32

DeleteBinObjBug

Reproducing DeleteBinObj and/or FastDev bug
Shell
2
star
33

Live.Forms.iOS

Xamarin.Forms live XAML reloading (iOS only)
C#
2
star
34

twitch-embeddinator

Demo project taking a Xamarin.Forms app and running it with Embeddinator-4000 in Android Studio
Java
2
star
35

maui-workload-pinning

This is an example of installing .NET MAUI Preview 7 and using RC1 packs
C#
2
star
36

XamarinAndroidBuildTimes

Quick repo I'll use to profile build times on different Xamarin.Android projects
PowerShell
2
star
37

Xamarin.Forms.Performance

Repo for testing performance in Xamarin.Forms on Android
C#
2
star
38

dotnet-using-task

Testing MSBuild <UsingTask/>
C#
2
star
39

Xamarin.Firebase.Messaging.Repro

Xamarin.Firebase.Messaging.Repro
C#
1
star
40

net6-finalizer-repro

Repro for: https://github.com/xamarin/xamarin-android/pull/6363#issuecomment-937379007
C#
1
star
41

Simulations

Levi's simulations
C#
1
star
42

class-lib-pack-r2r

Include ReadyToRun compiled assemblies in a NuGet/class library.
C#
1
star
43

GetRich

A mobile app that will basically make you rich if you submit it to the app store
C#
1
star
44

Embeddinator-MonoGame

Testing running MonoGame through Embeddinator
1
star
45

IntuneRepro

Trying to repro: https://github.com/msintuneappsdk/intune-app-sdk-xamarin/issues/5
C#
1
star
46

MSBuildIncrementalClean

This is a quick sample to figure out some nuances with MSBuild
PowerShell
1
star
47

MicrosoftExtensionsRepro

Trying to repro startup performance issue on Android
C#
1
star
48

gitinfotest

This is a repro for an MSBuild issue.
C#
1
star
49

maui-view-performance

Repo for measuring .NET MAUI views & page navigation
C#
1
star
50

inclusive-code-reviews-demo

Source code for my presentation "Using ML.NET and LLMs in C#"
C#
1
star