Using bind causes massive traffic in server side blazor
See original GitHub issueIm working on a small simple drawing tool in server side blazor using the latest template in VS2019 .net core 3-preview. When I was stress testing my app, adding 500 elements it became extremely unresponsive.
When inspecting the websocket connection i saw lots of packages over 35kb while moving the mouse. This does not make sense to me, because im not changing anything.
Anyways after some experiments I have located something suspecious causing this.
Using bind on an element like this:
1)<input type ="text" bind="@Text"/>
is completely diffrent then this:
2)<input type ="text" value="@Text" onchange="@(e=>e.Value)"/>
The first one is resending entire page over websocket each mouse move (which seems to be at least 10 times per second) The second one is resending entire page over websocket only when I change the text.
1)This one using bind sends 35kb packages
@page "/"
<div onmousemove="@(e=>MouseMove(e))">
@for(var i = 0; i < 1000; i++)
{
<input type ="text" bind="@Text"/>
}
</div>
@functions{
public string Text { get; set; }
public void MouseMove(UIMouseEventArgs e)
{
}
}
This one works as expected with regards to data sent over websocket
@page "/"
<div onmousemove="@(e=>MouseMove(e))">
@for(var i = 0; i < 1000; i++)
{
<input type ="text" value="@Text" onchange="@(e=>OnTextChange(e))"/>
}
</div>
@functions{
public string Text { get; set; }
public void MouseMove(UIMouseEventArgs e)
{
}
public void OnTextChange(UIChangeEventArgs e)
{
Text = e.Value.ToString();
}
}
Issue Analytics
- State:
- Created 4 years ago
- Comments:11 (7 by maintainers)
@ChristianWeyer yes im seeing this in latest bits.
Current steps to reproduce is having either section 1 or section 2 commented in. Run in any valid page.
`
`
Closing as dup of https://github.com/dotnet/aspnetcore/issues/10522.