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

Maui usage of Glide is preventing us from using our own model loaders #22465

Closed
hgjunip opened this issue May 16, 2024 · 2 comments
Closed

Maui usage of Glide is preventing us from using our own model loaders #22465

hgjunip opened this issue May 16, 2024 · 2 comments
Labels
area-controls-image Image control migration-compatibility Xamarin.Forms to .NET MAUI Migration, Upgrade Assistant, Try-Convert platform/android 🤖 s/needs-attention Issue has more information and needs another look t/bug Something isn't working

Comments

@hgjunip
Copy link

hgjunip commented May 16, 2024

Description

We are currently porting a xamarin forms app to MAUI. The app used Android Glide and in it we would add an AppGlideModule that helped us register a couple of model loader factories. But now MAUI has its own AppGlideModule which prevents us from adding one of our own. Glide documentation mentions: "Libraries must not include AppGlideModule implementations. Doing so will prevent any applications that depend on the library from managing their dependencies or configuring options like Glide’s cache sizes and locations.".
This is currently preventing us from using Glide which makes the performance of our app considerably worse. Any workaround or guidance is appreciated.

Steps to Reproduce

  1. Create an android binding library project and add an AppGlideModule to it.
  2. Create a Maui project which references the project created in 1.
  3. Try to build and it fails because if finds duplicates of some of the glide classes.

Link to public reproduction project repository

No response

Version with bug

8.0.7 SR2

Is this a regression from previous behavior?

Yes, this used to work in Xamarin.Forms

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

No response

Did you find any workaround?

We tried adding our glide module as a LibraryGlideModule but it fails to register correctly.

Relevant log output

No response

@hgjunip hgjunip added the t/bug Something isn't working label May 16, 2024
@PureWeen PureWeen added area-controls-image Image control platform/android 🤖 migration-compatibility Xamarin.Forms to .NET MAUI Migration, Upgrade Assistant, Try-Convert s/needs-repro Attach a solution or code which reproduces the issue labels May 16, 2024
@parth211prajapati
Copy link

You can resolve the conflict with Glide in your .NET MAUI project by removing the AppGlideModule from your Xamarin.Forms library and configuring Glide directly in your .NET MAUI project. This involves initializing Glide with the required options and registering any custom model loader factories in your MainActivity.cs (for Android) or AppDelegate.cs (for iOS) files. This approach avoids conflicts and allows you to customize Glide according to your needs.

@dotnet-policy-service dotnet-policy-service bot added s/needs-attention Issue has more information and needs another look and removed s/needs-repro Attach a solution or code which reproduces the issue labels May 20, 2024
@hgjunip
Copy link
Author

hgjunip commented May 20, 2024

Thanks I didn't know you could register model loaders after initialization. For anyone else who bumps into this, in my main activity I did this:
var glide = Glide.Get(this);
glide.Registry.Append(Class.FromType(typeof(Java.Lang.String)), Class.FromType(typeof(InputStream)), new FontImageSourceLoaderFactory(this));

@hgjunip hgjunip closed this as completed May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-controls-image Image control migration-compatibility Xamarin.Forms to .NET MAUI Migration, Upgrade Assistant, Try-Convert platform/android 🤖 s/needs-attention Issue has more information and needs another look t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants