-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
App Crash on Android due to ScrollViewHandler.DisconnectHandler call during Scroll Animation while navigating away from Page. #22443
Comments
Hi I'm an AI powered bot that finds similar issues based off the issue title. Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you! Open similar issues:
Closed similar issues:
|
Can repro this issue at Android platform on the latest 17.10 Preview 7(8.0.7&8.0.10&8.0.40). |
Yeah I have been able to recreate the issue using the latest .NET 9 Preview 3, and I can still see the problematic issue within the ScrollViewHandler.Android.cs line 150. |
@kubaflo Can you take a look at the improvements listed above and that should address this issue. |
@PureWeen |
Making the change from the merged PR does not resolve the issue. Please attempt the same steps as above with the updated repo -> https://github.com/PATRICKdallat/ScrollViewHandlerCrash |
@PATRICKdallat I think you should try with the latest nightly build |
@kubaflo |
Description
The android application experiences a crash when a user attempts to navigate back (i.e. removing the page from the stack) while a scroll animation is in progress and the ScrollViewHandler has been disconnected.
Here are three suggested improvements:
Refine the RequestScrollTo CommandMapping by adding a null-check for the VirtualView within the OnFinish Action Callback. This will prevent potential null reference errors.
Prior to disposing of the ScrollView from the ScrollViewHandler.DisconnectHandler, cancel the _scrollCompletionSource. This will ensure that no tasks are left open, improving resource management.
Create a publicly (or protected) accessible method to cancel the ScrollView Scroll animation task. This will provide greater flexibility and control over the Scroll animation.
Steps to Reproduce
Link to public reproduction project repository
https://github.com/PATRICKdallat/ScrollViewHandlerCrash
Version with bug
8.0.10 SR3
Is this a regression from previous behavior?
No, this is something new
Last version that worked well
Unknown/Other
Affected platforms
Android
Affected platform versions
No response
Did you find any workaround?
Replacing the CommandMapper for IScrollView.RequestScrollTo
` ScrollViewHandler.CommandMapper.ReplaceMapping<IScrollView, ScrollViewHandler>(nameof(IScrollView.RequestScrollTo), (handler, _, args) =>
{
var context = handler.PlatformView.Context;
Relevant log output
Android.Runtime.RuntimeNativeMethods.monodroid_debugger_unhandled_exception (Unknown Source:0) Android.Runtime.JNINativeWrapper._unhandled_exception (JNINativeWrapper.g.cs:13) Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PPL_V (JNINativeWrapper.g.cs:126) Microsoft.Maui.Handlers.ViewHandler<Microsoft.Maui.IScrollView,Microsoft.Maui.Platform.MauiScrollView>.get_VirtualView (ViewHandlerOfT.cs:42) Microsoft.Maui.Handlers.ScrollViewHandler.Microsoft.Maui.Handlers.IScrollViewHandler.get_VirtualView (ScrollViewHandler.cs:53) Microsoft.Maui.Handlers.ScrollViewHandler. (ScrollViewHandler.Android.cs:150) Microsoft.Maui.Platform.MauiScrollView. (MauiScrollView.cs:288) Android.Animation.AnimatorEventDispatcher.OnAnimationEnd (Animator.cs:86) Android.Animation.Animator.IAnimatorListenerInvoker.n_OnAnimationEnd_Landroid_animation_Animator_ (Android.Animation.Animator.cs:142) Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PPL_V (JNINativeWrapper.g.cs:125)
The text was updated successfully, but these errors were encountered: