question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Getting object disposed on blazorators.geolocation on webassembly when using watchposition and returning to the tab on the navigator

See original GitHub issue

I 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:closed
  • Created 7 months ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
allcontributors[bot]commented, Feb 22, 2023

@IEvangelist

@fabiansanchez18 already contributed before to bug

0reactions
IEvangelistcommented, Feb 22, 2023
Read more comments on GitHub >

github_iconTop Results From Across the Web

Blazor Server: Cannot access a disposed object.
I am using a new dbcontext object each time so I am confused why it is trying to access something that is disposed...
Read more >
Track Gps With Blazor Browserinterop
In this blog post, I will explain how to use this library for getting the user's geolocation and for knowing when the user...
Read more >
Geolocation in Blazor - Bernard Darnton
I wanted to return a single object, so I created a combined GeolocationResult class that had Position and Error properties. GeolocationResult ...
Read more >
Blazor WebAssembly - Dispose not firing on browser close
The dispose only seems to fire when navigating within the app itself (i.e. the page or control is disposed due to a navigation)....
Read more >
Blazor.Geolocation 7.0.3
The Blazor.Geolocation package consumes the Blazor.SourceGenerators package. It exposes a source generated IGeolocation interface specific to Blazor WebAssembly ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found