maui icon indicating copy to clipboard operation
maui copied to clipboard

GraphicsView does not call Drawable's Draw() after each Invalidate on iOS

Open maiiaKey opened this issue 3 years ago • 2 comments

Description

We are creating a custom Signature Pad control in Maui using GraphicsView as a basis and then we need to consume this control in native .Net6 iOS, Android and Windows projects. Since we want to display the stroke as soon as user draws it, we are calling GraphicsView.Invalidate() method each 50ms.

Observed behavior:

Android and Windows works as designed: the stroke appears as soon as user draws it However on iOS the stroke only appears after the user ends the touch.

Expected behavior:

The control works the same way on iOS as on Windows and Android.

Steps to Reproduce

Attaching a repro sample (contains a Maui library project and 3 native app projects) SignaturePadIos.zip

Version with bug

6.0.400

Last version that worked well

Unknown/Other

Affected platforms

iOS

Affected platform versions

iOS 15

Did you find any workaround?

No response

Relevant log output

No response

maiiaKey avatar Aug 23 '22 07:08 maiiaKey

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

ghost avatar Aug 23 '22 18:08 ghost

I am having a similar issue (although I swear it worked a month ago). I have a few graphicsviews in my app and only about 75% of them now call the draw method on Invalidate in iOS, so some controls just don't draw at all.

The controls work perfectly in Android and call Draw just fine.

WebGoose avatar Oct 27 '22 14:10 WebGoose

I have a similar issue, where an IDrawable is supposed to be refreshed constantly with a timer:

	var timer = new System.Timers.Timer(50);
	timer.Elapsed += new System.Timers.ElapsedEventHandler(UpdateDrawable);
	timer.Start();

	//UpdateDrawable just sets a view values and invalidates the drawable
	private void UpdateDrawable(object? sender, EventArgs e)
	{
	     //[...]
                DisplayView.Invalidate(); //DisplayView is of type GraphicsView
	}

On Windows this works as expected and well, on iOS this only works if UpdateDrawable() is called from a Button or any other "finished" UI interaction.

Dokug avatar Nov 23 '22 10:11 Dokug

You need to invoke a dispatcher into your ElapsedEvent:

Application.Current.MainPage.Dispatcher.Dispatch(() =>
{
    DisplayView.Invalidate();
});

To force the Invalidate call to be called on the UI Thread

rdessart avatar Jan 11 '23 15:01 rdessart