Getting object disposed on blazorators.geolocation on webassembly when using watchposition and returning to the tab on the navigator
See original GitHub issueI am getting the following Exception when the tab on the navigator looses focus:
Unhandled Exception: u @ blazor.webassembly.js:1 put_char @ dotnet..0sy4n0js1g.js:2171 write @ dotnet..0sy4n0js1g.js:2104 write @ dotnet..0sy4n0js1g.js:3394 doWritev @ dotnet..0sy4n0js1g.js:7546 _fd_write @ dotnet..0sy4n0js1g.js:7612 $__stdio_write @ 052e6932:0x7b8b20 $__fwritex @ 052e6932:0x7b96a7 $fwrite @ 052e6932:0x7b9758 $fputs @ 052e6932:0x7b917c $default_stderr_handler @ 052e6932:0x7a9b67 $monoeg_g_printerr @ 052e6932:0x7a9b49 $mono_print_unhandled_exception_internal @ 052e6932:0x626c20 $mono_unhandled_exception_checked @ 052e6932:0x626a2c $mono_unhandled_exception_internal @ 052e6932:0x6268f5 $mono_handle_exception_internal @ 052e6932:0x797596 $mono_handle_exception @ 052e6932:0x7957be $interp_throw @ 052e6932:0x59a980 $interp_exec_method @ 052e6932:0x5919c1 $interp_runtime_invoke @ 052e6932:0x58a231 $mono_jit_runtime_invoke @ 052e6932:0x783431 $do_runtime_invoke @ 052e6932:0x6228f9 $mono_runtime_try_invoke @ 052e6932:0x62308c $mono_runtime_invoke @ 052e6932:0x625352 $mono_wasm_invoke_method_ref @ 052e6932:0x7ec07e Module._mono_wasm_invoke_method_ref @ dotnet..0sy4n0js1g.js:8671 _Microsoft_AspNetCore_Components_WebAssembly__Microsoft_AspNetCore_Components_WebAssembly_Services_DefaultWebAssemblyJSRuntime_InvokeDotNet @ _Microsoft_AspNetCore_Components_WebAssembly__Microsoft_AspNetCore_Components_WebAssembly_Services_DefaultWebAssemblyJSRuntime_InvokeDotNet:29 invokeDotNetFromJS @ blazor.webassembly.js:1 g @ blazor.webassembly.js:1 invokeMethod @ blazor.webassembly.js:1 onSuccess @ blazorators.geolocation.g.js:19 (anonymous) @ blazorators.geolocation.g.js:52 System.ArgumentException: There is no tracked object with id '8'. Perhaps the DotNetObjectReference instance was already disposed. (Parameter 'dotNetObjectId') u @ blazor.webassembly.js:1 put_char @ dotnet..0sy4n0js1g.js:2171 write @ dotnet..0sy4n0js1g.js:2104 write @ dotnet..0sy4n0js1g.js:3394 doWritev @ dotnet..0sy4n0js1g.js:7546 _fd_write @ dotnet..0sy4n0js1g.js:7612 $__stdio_write @ 052e6932:0x7b8b20 $__fwritex @ 052e6932:0x7b96a7 $fwrite @ 052e6932:0x7b9758 $fputs @ 052e6932:0x7b917c $default_stderr_handler @ 052e6932:0x7a9b67 $monoeg_g_printerr @ 052e6932:0x7a9b49 $mono_print_unhandled_exception_internal @ 052e6932:0x626c20 $mono_unhandled_exception_checked @ 052e6932:0x626a2c $mono_unhandled_exception_internal @ 052e6932:0x6268f5 $mono_handle_exception_internal @ 052e6932:0x797596 $mono_handle_exception @ 052e6932:0x7957be $interp_throw @ 052e6932:0x59a980 $interp_exec_method @ 052e6932:0x5919c1 $interp_runtime_invoke @ 052e6932:0x58a231 $mono_jit_runtime_invoke @ 052e6932:0x783431 $do_runtime_invoke @ 052e6932:0x6228f9 $mono_runtime_try_invoke @ 052e6932:0x62308c $mono_runtime_invoke @ 052e6932:0x625352 $mono_wasm_invoke_method_ref @ 052e6932:0x7ec07e Module._mono_wasm_invoke_method_ref @ dotnet..0sy4n0js1g.js:8671 _Microsoft_AspNetCore_Components_WebAssembly__Microsoft_AspNetCore_Components_WebAssembly_Services_DefaultWebAssemblyJSRuntime_InvokeDotNet @ _Microsoft_AspNetCore_Components_WebAssembly__Microsoft_AspNetCore_Components_WebAssembly_Services_DefaultWebAssemblyJSRuntime_InvokeDotNet:29 invokeDotNetFromJS @ blazor.webassembly.js:1 g @ blazor.webassembly.js:1 invokeMethod @ blazor.webassembly.js:1 onSuccess @ blazorators.geolocation.g.js:19 (anonymous) @ blazorators.geolocation.g.js:52 at Microsoft.JSInterop.JSRuntime.GetObjectReference(Int64 dotNetObjectId) u @ blazor.webassembly.js:1 put_char @ dotnet..0sy4n0js1g.js:2171 write @ dotnet..0sy4n0js1g.js:2104 write @ dotnet..0sy4n0js1g.js:3394 doWritev @ dotnet..0sy4n0js1g.js:7546 _fd_write @ dotnet..0sy4n0js1g.js:7612 $__stdio_write @ 052e6932:0x7b8b20 $__fwritex @ 052e6932:0x7b96a7 $fwrite @ 052e6932:0x7b9758 $fputs @ 052e6932:0x7b917c $default_stderr_handler @ 052e6932:0x7a9b67 $monoeg_g_printerr @ 052e6932:0x7a9b49 $mono_print_unhandled_exception_internal @ 052e6932:0x626c20 $mono_unhandled_exception_checked @ 052e6932:0x626a2c $mono_unhandled_exception_internal @ 052e6932:0x6268f5 $mono_handle_exception_internal @ 052e6932:0x797596 $mono_handle_exception @ 052e6932:0x7957be $interp_throw @ 052e6932:0x59a980 $interp_exec_method @ 052e6932:0x5919c1 $interp_runtime_invoke @ 052e6932:0x58a231 $mono_jit_runtime_invoke @ 052e6932:0x783431 $do_runtime_invoke @ 052e6932:0x6228f9 $mono_runtime_try_invoke @ 052e6932:0x62308c $mono_runtime_invoke @ 052e6932:0x625352 $mono_wasm_invoke_method_ref @ 052e6932:0x7ec07e Module._mono_wasm_invoke_method_ref @ dotnet..0sy4n0js1g.js:8671 _Microsoft_AspNetCore_Components_WebAssembly__Microsoft_AspNetCore_Components_WebAssembly_Services_DefaultWebAssemblyJSRuntime_InvokeDotNet @ _Microsoft_AspNetCore_Components_WebAssembly__Microsoft_AspNetCore_Components_WebAssembly_Services_DefaultWebAssemblyJSRuntime_InvokeDotNet:29 invokeDotNetFromJS @ blazor.webassembly.js:1 g @ blazor.webassembly.js:1 invokeMethod @ blazor.webassembly.js:1 onSuccess @ blazorators.geolocation.g.js:19 (anonymous) @ blazorators.geolocation.g.js:52 at Microsoft.JSInterop.Infrastructure.DotNetDispatcher.Invoke(JSRuntime jsRuntime, DotNetInvocationInfo& invocationInfo, String argsJson) u @ blazor.webassembly.js:1 put_char @ dotnet..0sy4n0js1g.js:2171 write @ dotnet..0sy4n0js1g.js:2104 write @ dotnet..0sy4n0js1g.js:3394 doWritev @ dotnet..0sy4n0js1g.js:7546 _fd_write @ dotnet..0sy4n0js1g.js:7612 $__stdio_write @ 052e6932:0x7b8b20 $__fwritex @ 052e6932:0x7b96a7 $fwrite @ 052e6932:0x7b9758 $fputs @ 052e6932:0x7b917c $default_stderr_handler @ 052e6932:0x7a9b67 $monoeg_g_printerr @ 052e6932:0x7a9b49 $mono_print_unhandled_exception_internal @ 052e6932:0x626c20 $mono_unhandled_exception_checked @ 052e6932:0x626a2c $mono_unhandled_exception_internal @ 052e6932:0x6268f5 $mono_handle_exception_internal @ 052e6932:0x797596 $mono_handle_exception @ 052e6932:0x7957be $interp_throw @ 052e6932:0x59a980 $interp_exec_method @ 052e6932:0x5919c1 $interp_runtime_invoke @ 052e6932:0x58a231 $mono_jit_runtime_invoke @ 052e6932:0x783431 $do_runtime_invoke @ 052e6932:0x6228f9 $mono_runtime_try_invoke @ 052e6932:0x62308c $mono_runtime_invoke @ 052e6932:0x625352 $mono_wasm_invoke_method_ref @ 052e6932:0x7ec07e Module._mono_wasm_invoke_method_ref @ dotnet..0sy4n0js1g.js:8671 _Microsoft_AspNetCore_Components_WebAssembly__Microsoft_AspNetCore_Components_WebAssembly_Services_DefaultWebAssemblyJSRuntime_InvokeDotNet @ _Microsoft_AspNetCore_Components_WebAssembly__Microsoft_AspNetCore_Components_WebAssembly_Services_DefaultWebAssemblyJSRuntime_InvokeDotNet:29 invokeDotNetFromJS @ blazor.webassembly.js:1 g @ blazor.webassembly.js:1 invokeMethod @ blazor.webassembly.js:1 onSuccess @ blazorators.geolocation.g.js:19 (anonymous) @ blazorators.geolocation.g.js:52 at Microsoft.AspNetCore.Components.WebAssembly.Services.DefaultWebAssemblyJSRuntime.InvokeDotNet(String assemblyName, String methodIdentifier, String dotNetObjectId, String argsJson) u @ blazor.webassembly.js:1 put_char @ dotnet..0sy4n0js1g.js:2171 write @ dotnet..0sy4n0js1g.js:2104 write @ dotnet..0sy4n0js1g.js:3394 doWritev @ dotnet..0sy4n0js1g.js:7546 _fd_write @ dotnet..0sy4n0js1g.js:7612 $__stdio_write @ 052e6932:0x7b8b20 $__fwritex @ 052e6932:0x7b96a7 $fwrite @ 052e6932:0x7b9758 $fputs @ 052e6932:0x7b917c $default_stderr_handler @ 052e6932:0x7a9b67 $monoeg_g_printerr @ 052e6932:0x7a9b49 $mono_print_unhandled_exception_internal @ 052e6932:0x626c20 $mono_unhandled_exception_checked @ 052e6932:0x626a2c $mono_unhandled_exception_internal @ 052e6932:0x6268f5 $mono_handle_exception_internal @ 052e6932:0x797596 $mono_handle_exception @ 052e6932:0x7957be $interp_throw @ 052e6932:0x59a980 $interp_exec_method @ 052e6932:0x5919c1 $interp_runtime_invoke @ 052e6932:0x58a231 $mono_jit_runtime_invoke @ 052e6932:0x783431 $do_runtime_invoke @ 052e6932:0x6228f9 $mono_runtime_try_invoke @ 052e6932:0x62308c $mono_runtime_invoke @ 052e6932:0x625352 $mono_wasm_invoke_method_ref @ 052e6932:0x7ec07e Module._mono_wasm_invoke_method_ref @ dotnet..0sy4n0js1g.js:8671 _Microsoft_AspNetCore_Components_WebAssembly__Microsoft_AspNetCore_Components_WebAssembly_Services_DefaultWebAssemblyJSRuntime_InvokeDotNet @ _Microsoft_AspNetCore_Components_WebAssembly__Microsoft_AspNetCore_Components_WebAssembly_Services_DefaultWebAssemblyJSRuntime_InvokeDotNet:29 invokeDotNetFromJS @ blazor.webassembly.js:1 g @ blazor.webassembly.js:1 invokeMethod @ blazor.webassembly.js:1 onSuccess @ blazorators.geolocation.g.js:19 (anonymous) @ blazorators.geolocation.g.js:52 dotnet..0sy4n0js1g.js:5 Uncaught Error: System.ArgumentException: There is no tracked object with id '8'. Perhaps the DotNetObjectReference instance was already disposed. (Parameter 'dotNetObjectId') at Microsoft.JSInterop.JSRuntime.GetObjectReference(:7153/Int64 dotNetObjectId) at Microsoft.JSInterop.Infrastructure.DotNetDispatcher.Invoke(:7153/JSRuntime jsRuntime, DotNetInvocationInfo& invocationInfo, String argsJson) at Microsoft.AspNetCore.Components.WebAssembly.Services.DefaultWebAssemblyJSRuntime.InvokeDotNet(:7153/String assemblyName, String methodIdentifier, String dotNetObjectId, String argsJson) at qi (dotnet..0sy4n0js1g.js:5:80613) at Ji (dotnet..0sy4n0js1g.js:5:80497) at _Microsoft_AspNetCore_Components_WebAssembly__Microsoft_AspNetCore_Components_WebAssembly_Services_DefaultWebAssemblyJSRuntime_InvokeDotNet (_Microsoft_AspNetCore_Components_WebAssembly__Microsoft_AspNetCore_Components_WebAssembly_Services_DefaultWebAssemblyJSRuntime_InvokeDotNet:30:5) at Object.invokeDotNetFromJS (blazor.webassembly.js:1:45224) at g (blazor.webassembly.js:1:1621) at A.invokeMethod (blazor.webassembly.js:1:3812) at onSuccess (blazorators.geolocation.g.js:19:15) at blazorators.geolocation.g.js:52:21
It says the the reference is no longer there, that maybe it was disposed.
I was looking on the js code on blazorators.geolocation.g.js:
const onSuccess = (dotnetObj, successMethodName, position) => { // HACK: Blazor isn't correctly deserializing these. // It ignores the
JsonPropertyNameAttribute :( const result = { Timestamp: position.timestamp, Coords: { Accuracy: position.coords.accuracy, Altitude: position.coords.altitude, AltitudeAccuracy: position.coords.altitudeAccuracy, Heading: position.coords.heading, Latitude: position.coords.latitude, Longitude: position.coords.longitude, Speed: position.coords.speed } }; dotnetObj.invokeMethod(successMethodName, result); dotnetObj.dispose(); };
The error is on dotnetObj.invokeMethod. Maybe the GC cleans the object when the tab looses focus and when we return the execution fails. Perhaps it has something to do with the last line dotnetObj.dispose(). I suppose that we don’t need to dispose the object when using watchPosition.
Issue Analytics
- State:
- Created 7 months ago
- Comments:7 (4 by maintainers)
@IEvangelist
@fabiansanchez18 already contributed before to bug
@allcontributors please add @fabiansanchez18 for bug