-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[Core] Run only one forceSizeUpdate per 16 milliseconds #2040
Conversation
Xamarin.Forms.Core/Cells/Cell.cs
Outdated
@@ -19,6 +19,9 @@ public abstract class Cell : Element, ICellController, IFlowDirectionController | |||
|
|||
bool _nextCallToForceUpdateSizeQueued; | |||
|
|||
object _forceUpdateSizeLocker = new object(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like indentation is out of place here and on other lines as well.
@adrianknight89 sorry, it was my gap.. I had to uncheck "converting tabs to spaces" |
build |
I dont understand the point of this? Screen refresh rates can be greater than 60hz |
Xamarin.Forms.Core/Cells/Cell.cs
Outdated
@@ -19,6 +19,9 @@ public abstract class Cell : Element, ICellController, IFlowDirectionController | |||
|
|||
bool _nextCallToForceUpdateSizeQueued; | |||
|
|||
object _forceUpdateSizeLocker = new object(); | |||
Task _forceUpdateSizeDelayTask = Task.CompletedTask; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Compile error here:
Cells\Cell.cs(23,41): error CS0117: 'Task' does not contain a definition for 'CompletedTask' [C:\agent_work\2\s\Xamarin.Forms.Core\Xamarin.Forms.Core.csproj]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed this error by replacing Task.CompletedTask by Task.FromResult(true)
@jassmith I can't answer, nevertheless I noticed, that the implementation doesn't correspond to presented comment - "don't run more than once per 16 milliseconds" look through initial code So, I aligned code according to presented comment. |
Now, I hope, it will be built successfully |
I apologize, I was skipping through these notifications very fast and failed to properly read the diff. I remember why this is rate limited now. Its SUPER expensive :P |
build |
@AndreiMisiukevich unit test failed |
@AndreiMisiukevich I do not understand why the original version would run more than once every 16 milliseconds. Are you worried about this being called from multiple threads? |
@hartez yes, exactly. If write smth like code below class VCell : ViewCell
{
protected override void OnTapped()
{
base.OnTapped();
foreach(var task in Enumerable.Range(0, 10).Select(i => new Task(ForceUpdateSize)))
{
task.Start();
}
}
} |
Calling ForceUpdateSize from a non-UI thread is not supported. |
@AndreiMisiukevich @jassmith I am guessing that most handlers of that event need to run on the main thread. Perhaps it would make more sense to marshal all the calls to OnForceUpdateSizeRequested onto the main thread in the first place. Something like:
|
Okay, i see. I added new commit. see it above |
Thats not a bad point. Restarting your builds again. You probably should just null check that Task instead of Task.Delay(0) it, that is just waste. |
I dont want us to auto-marshal everything no. Supporting out of UI thread calls in just this one area will cause us more confusion than its worth. |
Colleagues, I think these changes aren't very important, are they? |
Does it show any visual change' like is the list faster , smoother ? |
We will not be taking this at this time. |
@AndreiMisiukevich @rmarinho Why is this closed? This is still an issue. See #2735 |
Description of Change
fixes #2039
Changed:
Behavioral Changes
Run only one forceSizeUpdate per 16 milliseconds