Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues;

public class Issue22443 : _IssuesUITest
{
public Issue22443(TestDevice device)
: base(device)
{ }

public override string Issue => "App Crash on Scroll Animation while navigating away from Page";

[Test]
public void NoExceptionShouldBeThrown()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test is failing on catalyst

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshot 2024-05-19 at 00 57 28 Should work now :)

{
App.WaitForElement("button");
App.Click("button");
App.WaitForElement("button");

//The test passes if no exception is thrown
}
}
7 changes: 7 additions & 0 deletions src/Controls/tests/TestCases/Issues/Issue22443.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Maui.Controls.Sample.Issues.Issue22443"
Title="Issue22443">
<Button Text="Navigate to next page" AutomationId="button" Clicked="Button_Clicked"/>
</ContentPage>
81 changes: 81 additions & 0 deletions src/Controls/tests/TestCases/Issues/Issue22443.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
using Microsoft.Maui.ApplicationModel;
using Microsoft.Maui.Controls;
using Microsoft.Maui.Controls.Xaml;
using Microsoft.Maui.Graphics;
using System;
using System.Threading.Tasks;

namespace Maui.Controls.Sample.Issues;

[XamlCompilation(XamlCompilationOptions.Compile)]
[Issue(IssueTracker.Github, 22443, "App Crash on Scroll Animation while navigating away from Page", PlatformAffected.Android)]
public partial class Issue22443NavPage : NavigationPage
{
public Issue22443NavPage() : base(new Issue22443())
{

}
}

public partial class Issue22443 : ContentPage
{
public Issue22443()
{
InitializeComponent();
}

void Button_Clicked(object sender, EventArgs e)
{
Navigation.PushAsync(new Issue22443ScrollPage());
}
}

public class Issue22443ScrollPage : ContentPage
{
private ScrollView _scrollView;

public Issue22443ScrollPage()
{
_scrollView = new ScrollView
{
Content = new VerticalStackLayout
{
Children =
{
new BoxView
{
HeightRequest = 10000,
Background = new LinearGradientBrush(
new GradientStopCollection
{
new GradientStop(Colors.White, .1f),
new GradientStop(Colors.Black, .9f)
})
},
new Label
{
FontSize = 40,
Text = "End of Second Page",
HorizontalOptions = LayoutOptions.Center,
},
}
}
};

Content = _scrollView;
}

protected override async void OnAppearing()
{
MainThread.BeginInvokeOnMainThread(() =>_scrollView!.ScrollToAsync(0, 10000, true));

await Task.Delay(200);
await Navigation.PopAsync();
}

protected override void OnDisappearing()
{
base.OnDisappearing();
_scrollView?.Handler?.DisconnectHandler();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,13 @@ public static void MapRequestScrollTo(IScrollViewHandler handler, IScrollView sc
var verticalOffsetDevice = (int)context.ToPixels(request.VerticalOffset);

handler.PlatformView.ScrollTo(horizontalOffsetDevice, verticalOffsetDevice,
request.Instant, () => handler.VirtualView.ScrollFinished());
request.Instant, () =>
{
if (handler.IsConnected())
{
handler.VirtualView.ScrollFinished();
}
});
}

/*
Expand Down