Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

handle SurfaceContentsLost, fake ImageSource. #15210

Closed
wants to merge 2 commits into from

Conversation

tonyhallett
Copy link
Contributor

Description of Change

React to the CompositionTarget.SurfaceContentsLost event ( that is the cause of the issue ) in the base renderer calling a new protected method to notify derivations that may need to update their image sources.
ImageRenderer, ImageButtonRenderer and ButtonRenderer all update image sources that require this functionality.
Image sources requiring this functionality implement a new interface IRecreateImageSource.
This is hacky as an ImageSource should be usable directly but it is the CanvasImageSource that necessitates this behaviour.

The best solution is an SvgImageSource instead of CanvasImageSource.
See #15070 (comment)

See https://microsoft.github.io/Win2D/WinUI3/html/M_Microsoft_Graphics_Canvas_UI_Xaml_CanvasImageSource_Recreate.htm and https://github.com/microsoft/Win2D-Samples/blob/c4106b22ac385719c3424021c9a58ca3ba8a9d07/ExampleGallery/ImageSourceUpdateRegion.xaml.cs for further details on SurfaceContentLost.

@jfversluis Can we work together to get this fixed as it severely limits Xamarin Forms as a cross platform framework.

Other solutions proposed.
#15070 and #15083.

Issues Resolved

fixes #8293 fixes #14323.

API Changes

As described above - UWP only.

Platforms Affected

  • UWP

Behavioral/Visual Changes

Can see images with source CanvasImageSource after minimize.

Before/After Screenshots

Not applicable

Testing Procedure

Added issue class.

PR Checklist

  • Targets the correct branch
  • Tests are passing (or failures are unrelated)

@tonyhallett
Copy link
Contributor Author

Sorry this should be draft as is a demonstration. I will add additional commits that set the actions to null when element changes require so.

@jfversluis
Copy link
Member

@jfversluis Can we work together to get this fixed as it severely limits Xamarin Forms as a cross platform framework.

Not sure what this would mean. I can review your PR, but other than that I don't think I can give this much priority, sorry.

@rmarinho
Copy link
Member

rmarinho commented Mar 7, 2022

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@tonyhallett
Copy link
Contributor Author

If it is agreed that this could be a solution to the mentioned issues it is important to not release until there is a discussion regarding what needs to be implemented from https://github.com/microsoft/Win2D-Samples/blob/c4106b22ac385719c3424021c9a58ca3ba8a9d07/ExampleGallery/ImageSourceUpdateRegion.xaml.cs
if any.

@tonyhallett
Copy link
Contributor Author

tonyhallett commented Mar 7, 2022

So firstly, is the solution acceptable ? Again I reiterate that using an SVGImageSource would be the best solution as it does not suffer from SurfaceContentsLost ( and thus no need for hacky fake ImageSource.). I have written code that converts the font in to an SVGImageSource but I am unable to get it to work. It is quite likely a minimal change for someone with SVGImageSource experience.

@jfversluis
Copy link
Member

Here's the thing. Anything we do for UWP right now is probably not reusable for .NET MAUI. That makes it hard to prioritize anything for UWP right now as the end-of-life of this is in sight.

I am willing to do a concession in this case if it's not the most perfect solution but it will work for you, but as mentioned before, I unfortunately can't spend any time on it myself because there are still a lot of other issues that either impact more people and can have more value because they can be ported to .NET MAUI.

I'm not trying to say I don't find your issue important, it's a matter of our priorities not really aligning here which sucks, I understand that.

If you can provide me with something working that I can review and verify and it passes the tests I am more than willing to help you out, but I'm afraid I can't give you any more help than that atm.

@tonyhallett
Copy link
Contributor Author

If you can provide me with something working that I can review and verify and it passes the tests I am more than willing to help you out, but I'm afraid I can't give you any more help than that atm.

On my machine this works both when minimize and when screen lock.

@jfversluis
Copy link
Member

Ah sorry, I misunderstood than as you mentioned something with the SVGImageSource and needing help. I'll have a look at this then!

@tonyhallett
Copy link
Contributor Author

@jfversluis
Can we got this in ?

@jfversluis
Copy link
Member

Thank you for all the time and effort here! I think at this point its safe to say that we won't be able to make this happen anymore. Your efforts have not gone unnoticed, appreciate it, thanks!

@jfversluis jfversluis closed this Nov 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
3 participants