none
v8 Script Error Debugging RRS feed

  • Question

  • Hi All,

    I have a few users that are getting scripting errors with my v8 bing maps control running in a Windows Forms environment.  I haven't yet been able to replicate them in my development environment.  The common point is that they say these don't happen right away but after a few hours of interacting with the map they appear.  

    So I'm guessing it might be memory related, perhaps I or the map aren't releasing memory as intended?  Or what does the 'AnonymousBegin' mean as it is common with both error messages.  Trouble is, I don't know how to debug these really as no line, char, etc. are listed for me.  Here are two captured images though.  Would these perhaps provide any guidance to anyone that could point me in the right direction on the means to debug this?  Thanks in advance.

    Thanks,

    Greg

    Monday, November 7, 2016 3:46 PM

Answers

  • Right, You need to specify that metadata tag when using Bing Maps inside of a WinForm or WPF browser as those browsers default to IE5 standards which don't support HTML5.

    [Blog] [twitter] [LinkedIn]

    Friday, December 9, 2016 2:20 PM
  • The URL won't provide any insight into what the issue is. AnonymousBegin is only one of many classes that are merged together and returned through a single URL. (if you look at the full URL you will see a bunch of class names. To debug, there are a few things that would need to be done:

    • Try and figure out if this error is occurring when your application does something, and if it is, determine which line of code that is. Try wrapping your code blocks with try/catch and inspecting the error object passed to the catch block. That should provide more insight into which line of code was called in your application before the error occurred.
    • It's possible that it is memory related. It would be useful to see the memory usage of the application when this error occurs. The Bing Maps V8 control appears to be much better at handling memory than previous versions of Bing Maps and I'd be surprised if this was the cause. It is worth noting that the web browser control in WinForm/WPF has a memory leak of it's own. This could be using up all the memory.
    • It's possible that the local storage may becoming too full. For performance the Bing Maps V8 control turns your data into map tiles. These tiles are then stored in local storage. This allows the map tiles to load the data without having to re-draw each individual shape, which provides a huge performance boost.
    • It's possible that if the map is loaded for too long that the session key that is generated for the map and used with the services, expires. If they are inly running the app for a few hours, this is unlikely the case. But if they are running that app 8+ hours then this could be the issue.

    What ever the cause, it will be hard to determine, especially if it takes hours for the error to even occur.  I'll see if I can set up a couple of automated tests on my end to see if I can reproduce the issue. I will run these tests in IE11 as that is likely the browser the WinForm app is emulating. If I can't reproduce this issue using IE11 on it's own, then the issue is likely either in your code or with the web browser control in WinForms. If it is the web browser control, then there likely isn't much the Bing Maps team can do. One possible solution would be to see if their is another web browser control that can be used. I think I've seen a couple open source ones around.


    [Blog] [twitter] [LinkedIn]

    Monday, November 7, 2016 6:01 PM
  • You need to step through your code and figure out where these error occurs. The error message from the Bing Maps control can be caused by any number of issues in your app (i.e. passing in string versions of numbers into the Location class rather than actual numbers). You need to figure out what line of code is firing in your app when the error occurs. Once this is known we can look at that and determine if there is a coding issue in your application of if there is an issue in the API.

    [Blog] [twitter] [LinkedIn]

    Friday, December 9, 2016 11:16 AM
  • Thanks fot the reply. 

    If I add the following line in my html page it's ok but Internet Explorer starts and load the page 'https://www.bing.com/fd/ls/lsp.aspx' (Nothing is displayed in Internet Explorer).

    <meta charset="utf-8" http-equiv="X-UA-Compatible" content="IE=edge" />

    Bing maps is correctly displayed in my application..

    Tnaks for your help.


    Friday, December 9, 2016 12:52 PM
  • I've gone through and tried to reproduce this issue but haven't had any luck, it has worked for me every time. I have put together a sample app that loads Bing Maps V8 in a WinForm WebBrowser control, and provides examples of calling JavaScript from C# and C# from JavaScript. You can download the code sample here: https://code.msdn.microsoft.com/Using-the-Bing-Maps-V8-Web-07e21f3a


    [Blog] [twitter] [LinkedIn]

    Wednesday, December 14, 2016 1:51 PM
  • The increased memory usage is expected. Since the map needs to render a canvas every time the map moves, it generates tiles out of the rendered data and stores them in memory that way when the map is panned and zoomed to an area that has already been rendered, it loads fast.

    How long is the application running before users are seeing errors? I've tried running a single map instance for a couple hours without any issues.


    [Blog] [twitter] [LinkedIn]

    Thursday, December 22, 2016 8:14 PM
  • Think I managed to reproduce the issue after a few hours of rendering large data sets (100mb+). What type of data are you rendering? Is it a lot of pushpins polylines, polygons, or tile layers? Is the data set constantly updating such as animating the position or fast updating data like gps positions? Once I know this I think I'll be able to narrow down the issue.

    as for catching the error, this is likely occurring inside an async function which makes it difficult to catch.


    [Blog] [twitter] [LinkedIn]

    Saturday, December 24, 2016 11:11 AM

All replies

  • The URL won't provide any insight into what the issue is. AnonymousBegin is only one of many classes that are merged together and returned through a single URL. (if you look at the full URL you will see a bunch of class names. To debug, there are a few things that would need to be done:

    • Try and figure out if this error is occurring when your application does something, and if it is, determine which line of code that is. Try wrapping your code blocks with try/catch and inspecting the error object passed to the catch block. That should provide more insight into which line of code was called in your application before the error occurred.
    • It's possible that it is memory related. It would be useful to see the memory usage of the application when this error occurs. The Bing Maps V8 control appears to be much better at handling memory than previous versions of Bing Maps and I'd be surprised if this was the cause. It is worth noting that the web browser control in WinForm/WPF has a memory leak of it's own. This could be using up all the memory.
    • It's possible that the local storage may becoming too full. For performance the Bing Maps V8 control turns your data into map tiles. These tiles are then stored in local storage. This allows the map tiles to load the data without having to re-draw each individual shape, which provides a huge performance boost.
    • It's possible that if the map is loaded for too long that the session key that is generated for the map and used with the services, expires. If they are inly running the app for a few hours, this is unlikely the case. But if they are running that app 8+ hours then this could be the issue.

    What ever the cause, it will be hard to determine, especially if it takes hours for the error to even occur.  I'll see if I can set up a couple of automated tests on my end to see if I can reproduce the issue. I will run these tests in IE11 as that is likely the browser the WinForm app is emulating. If I can't reproduce this issue using IE11 on it's own, then the issue is likely either in your code or with the web browser control in WinForms. If it is the web browser control, then there likely isn't much the Bing Maps team can do. One possible solution would be to see if their is another web browser control that can be used. I think I've seen a couple open source ones around.


    [Blog] [twitter] [LinkedIn]

    Monday, November 7, 2016 6:01 PM
  • Hi,

    I'm migrating to AJAX V8 and I got the same error. I don't know where the problem come from. Any news ?

    The html file is loaded using the class System.Windows.Forms.WebBrowser in a winform application. Hope this helps....


    • Edited by Marvel2048 Thursday, December 8, 2016 10:19 PM
    Thursday, December 8, 2016 9:58 PM
  • You need to step through your code and figure out where these error occurs. The error message from the Bing Maps control can be caused by any number of issues in your app (i.e. passing in string versions of numbers into the Location class rather than actual numbers). You need to figure out what line of code is firing in your app when the error occurs. Once this is known we can look at that and determine if there is a coding issue in your application of if there is an issue in the API.

    [Blog] [twitter] [LinkedIn]

    Friday, December 9, 2016 11:16 AM
  • Thanks fot the reply. 

    If I add the following line in my html page it's ok but Internet Explorer starts and load the page 'https://www.bing.com/fd/ls/lsp.aspx' (Nothing is displayed in Internet Explorer).

    <meta charset="utf-8" http-equiv="X-UA-Compatible" content="IE=edge" />

    Bing maps is correctly displayed in my application..

    Tnaks for your help.


    Friday, December 9, 2016 12:52 PM
  • Right, You need to specify that metadata tag when using Bing Maps inside of a WinForm or WPF browser as those browsers default to IE5 standards which don't support HTML5.

    [Blog] [twitter] [LinkedIn]

    Friday, December 9, 2016 2:20 PM
  • Thanks,

    But do you know why  IE opens ? Is there a way to prevent that ? 

    Friday, December 9, 2016 8:36 PM
  • Ie shouldn't open. The browser in wpf and inform is an ie emulator. There is no way around that, that's how the web browser control works.

    [Blog] [twitter] [LinkedIn]

    Friday, December 9, 2016 11:25 PM
  • I agree that it shouldn't open but it opens and load the page 'https://www.bing.com/fd/ls/lsp.aspx'

    My application is a Winform application not o WPF app.

    • Edited by Marvel2048 Wednesday, December 14, 2016 9:38 AM
    Wednesday, December 14, 2016 9:37 AM
  • I've gone through and tried to reproduce this issue but haven't had any luck, it has worked for me every time. I have put together a sample app that loads Bing Maps V8 in a WinForm WebBrowser control, and provides examples of calling JavaScript from C# and C# from JavaScript. You can download the code sample here: https://code.msdn.microsoft.com/Using-the-Bing-Maps-V8-Web-07e21f3a


    [Blog] [twitter] [LinkedIn]

    Wednesday, December 14, 2016 1:51 PM
  • I had this meta data tag you'd mentioned (below) all along, so it can't really be causing the issue for me.  I have try/catch on every line of code in my application but yet it doesn't trap this error.  Rather it crops-up on its own after extended use.  The longer the map control is used interactively the more likely these are to appear for the end users.  I've still therefore not captured how/why this happens.  I've pretty thoroughly inspected the code, I don't see any type conversion issues as you'd mentioned.  I did notice that as I pan the map it uses 2x the memory pretty instantly vs. v7 and with continued use the memory usage gets quite aggressive with hundreds of megabytes being allocated.  I've made a bare bones vanilla test app with only the min html but within a WinForms browser control, no javascript, and just pan like mad and even then the memory allocation is much greater than with v7.  So my hunch is that it is memory related but I'll continue to test and try to unearth what is the root cause of this.

    <meta charset="utf-8" http-equiv="X-UA-Compatible" content="IE=edge" />

    Thursday, December 22, 2016 5:48 PM
  • The increased memory usage is expected. Since the map needs to render a canvas every time the map moves, it generates tiles out of the rendered data and stores them in memory that way when the map is panned and zoomed to an area that has already been rendered, it loads fast.

    How long is the application running before users are seeing errors? I've tried running a single map instance for a couple hours without any issues.


    [Blog] [twitter] [LinkedIn]

    Thursday, December 22, 2016 8:14 PM
  • We want to put in some diagnostics tools so that we can trap more information such as the duration, map interactions (pans and zooms), etc. and are working on that.  According to the end users it happens anywhere from an hour into use to several hours.  The latter being far more common as an explanation.

    Completely understood that it might require additional memory with HTML5 canvas.  I'm just speculating that the issue is memory related as I see it as being the single most divergent aspect of v7 vs. v8 usage.  We'll keep testing meanwhile.  With that said though, any idea why we can't seem to truly trap this error?  I have triple checked really and don't know any place where an error could go undetected or unlogged from within our map control code.

    Thx, -Greg

    Saturday, December 24, 2016 1:19 AM
  • Think I managed to reproduce the issue after a few hours of rendering large data sets (100mb+). What type of data are you rendering? Is it a lot of pushpins polylines, polygons, or tile layers? Is the data set constantly updating such as animating the position or fast updating data like gps positions? Once I know this I think I'll be able to narrow down the issue.

    as for catching the error, this is likely occurring inside an async function which makes it difficult to catch.


    [Blog] [twitter] [LinkedIn]

    Saturday, December 24, 2016 11:11 AM
  • Ricky,

    Thanks for your assistance thus far and it is encouraging that you might have a lead.  

    We're displaying routed stops.  So yes, a great many pushpins (hundreds, potentially a thousand at a time) and also polylines representing the turn maneuvers.  The routes are shown and reshown potentially hundreds of times though as they are presented for editing and tweaking.  We don't do anything related to custom layers of overlays otherwise.  

    We have no live feed whatsoever such as showing tracking positions.  There is no auto-refresh of any kind, but as mentioned there are many refreshes manually invoked by showing RouteA first, then toggling to RouteB later, etc.

    There is some minor drawing also of rectangles/polygons that that is all quite minimal as compared to the rendering of the pushpins/polylines.

    Hopefully that helps.  Agreed, difficult to catch for us as well!

    Greg

    Tuesday, January 3, 2017 9:44 PM