Skip to content
Merged
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
17 changes: 14 additions & 3 deletions src/Browser/Avalonia.Browser/BrowserInputHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,12 @@ public bool OnPointerMove(string pointerType, long pointerId, double offsetX, do
{
coalescedEvents = new Lazy<IReadOnlyList<RawPointerPoint>?>(() =>
{
if (argsObj.IsDisposed)
return [];

// To minimize JS interop usage, we resolve all points properties in a single call.
const int itemsPerPoint = 6;
var pointsProps = InputHelper.GetCoalescedEvents(argsObj);
argsObj.Dispose();
s_intermediatePointsPooledList.Clear();

var pointsCount = pointsProps.Length / itemsPerPoint;
Expand All @@ -101,8 +103,17 @@ public bool OnPointerMove(string pointerType, long pointerId, double offsetX, do
});
}

return RawPointerEvent(type, pointerType!, point, (RawInputModifiers)modifier, pointerId,
coalescedEvents);
try
{
return RawPointerEvent(type, pointerType!, point, (RawInputModifiers)modifier, pointerId,
coalescedEvents);
}
finally
{
// Release the JS handle after processing the event.
// ImmediatePoints is only expected to be accessed synchronously during event processing.
argsObj.Dispose();
}
}

public bool OnPointerDown(string pointerType, long pointerId, int buttons, double offsetX, double offsetY,
Expand Down