-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
[Spec] ImageSourceHandler #480
Comments
I am looking at this now and I might not be thinking outside the box enough. With things like WinUI/UWP, it appears the ImageSource sometimes has events, for example:
The nice thing is that there are events tied directly to the source that it is happening on. However, for MAUI, this is a bit different as the As it is now, the In order to get consistent events on the For example, on Android, there is the service that directly gets the view to do the work. We are going to use Glide for this now but there is no bitmap object to store in the |
@mattleibow, thinking aloud here. If inside the ImageSource we have a Stream or byte array that stores the current With this approach, we need to care about disposing of that Stream, not sure if this easy to do. Also, making it immutable can reduce the complexity (?) |
@pictos that was my thinking, however, based on the things I see that libraries do this might not always work out. For example, if we have a look at the way Glide works, they have a "optimized path" that really says "load this URI into this view" and does not need us to interact with any bitmap objects at all. This also restrict the caching mechanisms. For example, if you want to have a tiered cache with say a memory and then a disk cache (like Glide does today), we will have to make the ImageSource objects more complex as they will now have to either do this caching, or interact with services to find some cache mechanism if the dev wants to override. If we have the image handler do all the work, then the ImageSource is very simple, and any custom handler can use a complete library (Glide) or have a combination of image loader and caching systems. |
One thing that I did come across was a way to release objects. Glide ties a bitmap reference count to the target. This could be the image or the image view. For example, if I load a bitmap into an image view, Glide will mark that bitmap as referenced 1 time. When I clear the image view (say if Source = null) then I need to go back to Glide and say deref the view/bitmap. This is easier with image views in some ways. However, this is harder with other views/objects. For example, a Button can have an image, and the only way we can do that is by asking Glide for a Drawable instance, and then manually assigning it to the native button. To do this, we have an ITarget object, which is a custom Glide object that is used by us to track the image loading - and we get the Drawable from that ITarget object. When the dev clears the image (or changes it), then we need to go back to Glide and say "we are no longer using this ITarget object" and then it goes and derefs it. I was thinking that we could go add a ref to this target object in the ImageSource? Maybe like a "cache key" and then the various handlers can first check that if they want before going to the underlying loading library. The issue is still, how do we clear the image? Is there a way to know when there are no more references to the ImageSource and then we can pass it back to the image library and say "we are done with this key"? |
@mattleibow yeah, I think that having a target object reference to the ImageSource could be great, can be something simple like an Probably this will end with something more robust but on my silly mind that can work, thoughts? |
My PR that was just merged has the basics in place - services and events. The actual events and placeholders on the control can come later. I have an events API that can be used to get notified of events on the control and images can be swapped out at any time. |
I am thinking for this we actually may want to have a separate control that uses the VSM to do this thing. Depending on status, it can switch between states - I think the WCT does this with ImageEx |
Hmm I take it we are not getting these features then? |
@Redth isn’t .NET 8 a little bit too far to have this working right now, or is it out already or know any workaround? Just curious. |
Do we have any workaround for this? We need a notification when the image has been successfully loaded into view. |
Any update on when the loading and error placeholder will be implemented? |
Team, do know perhaps the timeline to at least expect this functionality or some workaround? |
Certainly would be helpful. |
[ImageSource]
Create a service that handles the ImageSource logic on shared code based on this discussion between me, @PureWeen, and @mattleibow.
The general idea is to have an ImageSource handler class that will handle all ImageSource updates in the shared layer and reflects them to the Control.
API
[ IImageSourceHandler]
Properties
Events
Scenarios
Backward Compatibility
Minimum API levels?
Breaking changes?
Unsupported platforms?
Difficulty: medium
The text was updated successfully, but these errors were encountered: