Skip to content
This repository was archived by the owner on Jun 5, 2023. It is now read-only.

Two bound events shortly firing after eachother trigger concurrency bug. #88

Open
jspuij opened this issue Mar 16, 2020 · 0 comments
Open

Comments

@jspuij
Copy link

jspuij commented Mar 16, 2020

Minimal Repro here:

https://github.com/jspuij/WebWindow/tree/eventbug

The keydown and oninput events fire shortly after eachother and trigger some sort of concurrency issue. The error message to the console is:

Uncaught (in promise) Error: System.ArgumentException: There is no event handler associated with this event. EventId: '7'. (Parameter 'eventHandlerId')
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.DispatchEventAsync(/UInt64 eventHandlerId, EventFieldInfo fieldInfo, EventArgs eventArgs)
   at WebWindows.Blazor.JSInteropMethods.DispatchEvent(/WebEventDescriptor eventDescriptor, String eventArgsJson)
    at Object.endInvokeDotNetFromJS (Microsoft.JSInterop.js:162)
    at Boot.Desktop.ts:33
    at IPC.ts:44
    at Array.forEach (<anonymous>)
    at IPC.ts:44
    at EventTarget.<anonymous> (<anonymous>:1:202)
    at <anonymous>:1:650
    at <anonymous>:1:676

What seems to happen is that the renderer does not like asynchronous dispatch of multiple events in such short order. I've written the IPC messages to the debugger, and the order seems to be:

ipc:BeginInvokeDotNetFromJS ["1","WebWindow","DispatchEvent",0,"[{\"browserRendererId\":0,\"eventHandlerId\":3,\"eventArgsType\":\"keyboard\",\"eventFieldInfo\":{\"componentId\":6,\"fieldValue\":\"\"}},\"{\\\"type\\\":\\\"keydown\\\",\\\"key\\\":\\\"Unidentified\\\",\\\"code\\\":\\\"\\\",\\\"location\\\":0,\\\"repeat\\\":false,\\\"ctrlKey\\\":false,\\\"shiftKey\\\":false,\\\"altKey\\\":false,\\\"metaKey\\\":false}\"]"]
ipc:BeginInvokeDotNetFromJS ["2","WebWindow","DispatchEvent",0,"[{\"browserRendererId\":0,\"eventHandlerId\":4,\"eventArgsType\":\"change\",\"eventFieldInfo\":{\"componentId\":6,\"fieldValue\":\"a\"}},\"{\\\"type\\\":\\\"input\\\",\\\"value\\\":\\\"a\\\"}\"]"]
JS.RenderBatch:[0,"BgAAAAEAAAADAAAAAQAAAAAAAAD/////AQAAAAAAAAABAAAAAwAAAAAAAAD/////BQAAAAAAAAAAAAAAAQAAAAQAAAAAAAAAB29uaW5wdXRIAAAAGAAAACAAAAA4AAAAPAAAAFAAAAA="]
JS.EndInvokeDotNet:["1",true]
JS.EndInvokeDotNet:["2",false,"System.ArgumentException: There is no event handler associated with this event. EventId: \u00274\u0027.

What I think happens is that either the render or first EndInvokeDotNet clears up all the remaining eventHandlerIds, and subsequently the second EndInvokeDotNet fails. This halts the updating of the binding. (keydown is processed as it's the first event).

I'm not familiar enough with the inner workings of the renderer and dispatcher to tackle this easily myself.

jspuij added a commit to jspuij/WebWindow that referenced this issue Mar 17, 2020
jspuij added a commit to jspuij/WebWindow that referenced this issue Mar 17, 2020
jspuij added a commit to jspuij/WebWindow that referenced this issue Mar 17, 2020
jspuij added a commit to jspuij/MobileBlazorBindings that referenced this issue Jul 8, 2020
Eilon pushed a commit to dotnet/MobileBlazorBindings that referenced this issue Jul 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant