Thanks to visit codestin.com
Credit goes to github.com

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

1822 DrawingView fix freezing #1827

Merged
merged 7 commits into from
Mar 15, 2022
Merged

1822 DrawingView fix freezing #1827

merged 7 commits into from
Mar 15, 2022

Conversation

VladislavAntonyuk
Copy link
Contributor

@VladislavAntonyuk VladislavAntonyuk commented Mar 9, 2022

Description of Bug

Issues Fixed

Behavioral Changes

because of smoothing collection of points changed each time the user draws the line. as a result, led to more than 1 million points which took time to process. We shouldn't change the original (drawn) collection of points but should smooth the path only to visualize it.
The fix also includes enabling smoothing for all platforms (previously it was only for iOS/macOS) and minor nullable leftovers

PR Checklist

  • Has a linked Issue, and the Issue has been approved
  • Has tests (if omitted, state reason in description)
  • Has samples (if omitted, state reason in description)
  • Rebased on top of main at time of PR
  • Changes adhere to coding standard

@VladislavAntonyuk VladislavAntonyuk force-pushed the 1822-drawingview-freeze branch from df1ff8c to 5601a80 Compare March 9, 2022 19:29
/// <summary>
/// Get smoothed path.
/// </summary>
public static ObservableCollection<Point> SmoothedPathWithGranularity(this ObservableCollection<Point> currentPoints,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

extracted from iOS and applied smoothed path to all platforms

Copy link
Contributor

@pictos pictos Mar 9, 2022

Choose a reason for hiding this comment

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

This will change something in the final result for the user? If so, we can't do this here.

And I'm not saying in the code point of view, but in how that will look in the application visually.

Copy link
Contributor Author

@VladislavAntonyuk VladislavAntonyuk Mar 9, 2022

Choose a reason for hiding this comment

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

it is not about the new functionality. it is closer to a bug (especially for Android) if line smooth enabled.
This functionality worked only on iOS. But expected to work on all platforms.
You can compare the current version with the main branch. most likely you won't see the difference

@@ -78,7 +78,7 @@ protected override void OnElementPropertyChanged(object sender, PropertyChangedE
}
}

void OnLinesCollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) => LoadPoints(surface!);
void OnLinesCollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) => LoadPoints(surface);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

fix nullable

@@ -49,6 +50,7 @@ protected override void OnElementPropertyChanged(object sender, PropertyChangedE

public override void TouchesBegan(NSSet touches, UIEvent? evt)
{
DetectScrollViews();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

get scrollview parent renderers only once


void LoadPoints()
{
currentPath.RemoveAllPoints();
foreach (var line in Element.Lines)
{
UpdatePath(line);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

the root cause of the issue. infinite smoothing the path with updating all points. now points are not changed. only visual picture is smoothed

@@ -31,7 +30,9 @@ protected override void OnElementChanged(ElementChangedEventArgs<DrawingView> e)
if (Element != null)
{
WantsLayer = true;
Layer!.BackgroundColor = Element.BackgroundColor.ToCGColor();
if (Layer is not null)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

fix nullable

@TheCodeTraveler TheCodeTraveler enabled auto-merge (squash) March 15, 2022 02:41
@TheCodeTraveler TheCodeTraveler merged commit a13cd36 into main Mar 15, 2022
@TheCodeTraveler TheCodeTraveler deleted the 1822-drawingview-freeze branch March 15, 2022 02:41
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] [ios] DrawingView freezes when more than 5 lines
3 participants