What causes Google Maps javascript exceptions? - javascript

I pretty consistently get GMaps API javascript exceptions that look like the following:
Ve.k is null or not an object (FF & IE)
b.k is null or not an object (FF & IE)
a is null (FF)
a.$e is undefined (FF)
Uncaught TypeError: Cannot read property 'k' of undefined (chrome)
Often the exception occurs during an eval of some expression in javascript in the bowels of the GMaps API
Almost anything can cause one of these to pop up, displaying an overlay on the map or a mouse click event for example.
I've been scouring my code for some time looking for offending overlays, and event handlers, but so far no relationship found. I've had this happen on a naked map with no overlays or handlers active.
Certain versions of the API will not crash on certain browsers, but it's hit and miss and I still have this sinking susspicion that something in the environment is giving GMaps a hard time (eg. maybe Facebook Connect, Google Analytics, my code...)
Does anyone have a handle on what causes these?

After spending quite a bit of time rolling back operations that affected the map 1 by 1, I finally got to the line(s) that caused this problem.
First, if I removed the call to setUIToDefault() the problem went away, this was unacceptable to me both because I wanted the default UI and that's a lame way to solve the problem. So many more map operations later I came to the GWT calls:
mapWidget.setHeight()
mapWidget.setWidth().
For those not familiar with GWT these two calls will ultimately translate to the following javascript template call:
element.style['height'] = height;
where 'element' in this case is the div that contains the map and height on the RHS of the expression is something like "690px".
That was all it took to derail the maps API.
The fix? Setting the size of the map div prior to instantiating the map.
You tell me, bug in the maps api or just a major feature lack? I'm going to check w/ the maps folks.

Just the perils of using a minified, obfuscated Javascript library I am afraid. There is no discrete group of errors that result in the exceptions you are seeing, but you can be sure that they are a result of a bug in your own code. I use Google maps pretty extensively and have regularly seen these types of errors. In 100% of cases, the bug was mine.
If you post (either here or in new questions) specific examples of pages that generate these errors, we can check them out and hopefully fix them.

I would have to guess it would be your code (not to say your a bad programmer) or another library interfering. I've been using the Google MAPS API happily for about 1 year now* and never had the first exception. The only time I've ever gotten an error message was when I was adding the balloon thingy.
*The website looks like crap but it was a high school project for my county fair and I couldn't use any server side stuff.
Edit: After reading your comment I'm wondering if you included a proper DOCTYPE? Check and see if you have it.

Related

doc.pageWindowRect and doc.media are undefined in Adobe Acrobat Javascript

I'm using the Javascript API built-in to the Adobe Acrobat products, and trying to access the doc.pageWindowRect attribute.
I originally found that doc.pageWindowRect was undefined whenever I tried to access it, and through various posts on the AdobeUsers forum, found that I needed to activate the media extension first, by running something like console.println(this.media);
Normally this prints a result like: [object DocMedia]
However, on some computers used by our client, this just prints undefined instead. It seems that having this.media remain undefined means that doc.pageWindowRect will stay undefined too.
Does anyone know how to make sure this.media is defined, and thus enable doc.pageWindowRect? Or any other way of getting hold of the doc.pageWindowRect information?
I wondered if there might be a delay in activating the media extension (a suggestion I found online), and have tried repeatedly running code to display this.media and doc.pageWindowRect using app.setInterval, but even after waiting for a couple of minutes, they are still not defined.
Any suggestions would be greatly appreciated.
It seems that having this.media remain undefined means that
doc.pageWindowRect will stay undefined too.
Does anyone know how to [...] enable doc.pageWindowRect?
pageWindowRect belongs to the multimedia.api plugin. In Acrobat 9 and possibly other versions, this plugin is not by default loaded.
From what I can find in that scenario, one method for loading the multimedia.api plugin is to actually have media in the PDF file.
Default location for this plugin is: %Program Files%\Adobe\Reader 11.0\Reader\plug_ins\Multimedia.api
This might not be the fixing answer, but I hope the suggestion gives some insight. Good luck!

"ResizeObserver - loop limit exceeded" | API is never used

I am running a hybrid PhoneGap app (for a several years, running Cordova Android 6.1.2, more recently 9.0); for years, our #1 javascript error by a significant margin has been
ResizeObserver loop limit exceeded
However, the key distinction for my issue compared to the many other reports found on Google of this error is is that there are 0 instances of ResizeObserver being used anywhere in my code. Searching my entire computer, the only instance of ResizeObserver showing up anywhere is a random Steam file. Looking at my app while it's running, setting window.ResizeObserver = undefined doesn't break/do anything and document.resizeObservers (per the W3C documentation) returns nothing.
I have seen this post, which seems to be the canonical one for this error: ResizeObserver - loop limit exceeded . The answer of "This error means that ResizeObserver was not able to deliver all observations within a single animation frame. It is benign (your site will not break)." would be sufficient for me if I was actually using ResizeObserver. Since I am not using it, I am concerned that this error showing up is indicative of something larger going wrong.
There is no discernible pattern from our users' Chrome version/locale/time zone/Android version/etc/etc, unfortunately.
I've researched this API extensively and have found nothing that would indicate to my issue; either why there would be some sort of phantom ResizeObserver running and/or why that error would show up in an app that doesn't use that API.
Any help here (even just a vague direction to look at) would be very much appreciated. Thanks so much!
https://bugs.chromium.org/p/chromium/issues/detail?id=809574
Even the browser's Shadow DOM may be using this API, and cause this error to fire.
You can still safely ignore it.

How can I hook into new message windows using a bootstrapped Thunderbird extension?

I am currently trying to create a Thunderbird extension that write the recipients of a draft into the title of the composing window.
The default behaviour of Thunderbird is Compose: [Subject] (translated from German, YMMV), but I'd like to have something like this: Compose to [recipient(s)]: [Subject], so my time tracking software can keep track of the time I spend writing emails to clients.
My general idea for this extension is:
Hook into every composing window that is created / opened (I know they are reused) via event listeners
For every window, listen to the event recipients_changed, if such a thing exists. Otherwise, it's a bit more work (monitor all recipient input fields), but that should not be a problem.
Also listen for subject_changed (easier, because it's only one input) to prevent the default title overwriting our extended title.
I have already created a skeleton extension (bootstrapped), and the startup function in bootstrap.js is actually getting called. Since this is my first extension to Firefox/Thunderbird, this is the first success! :)
However, the only reason I know the function is called because the many exceptions my different trials have thrown are logged in the error console...
I have read many texts, but the learning curve seems to be pretty steep.
I learned that at the time startup is called, pretty much nothing is defined yet (my first attempts were alert and then settimeout).
This answer looked promising, but it throws the exception 'wm' is not defined:
https://stackoverflow.com/a/14291575/1886765
Maybe I used the code wrongly - hard to say for a beginner.
It would probably be easier to make a non-bootstrapped extension (I could overlay the compose window and wouldn't need step #1), but now that I've started this way, I'd like to finish it this way.
Maybe the solution is some XPCOM connector, but this field is still completely dark for me.
Could you kindly point me in the right direction?

Using JS (In FF-Pentadactyl), how to get a handle to site content like media players?

Using the Firefox Web Console (which can be brought up with control shift k ) I can easily access things like flowplayers.
jwplayer().play(), for example
The console even offers autocompletion suggestions for it.
What does the console do to be in that kind of, for my lack of words and knowledge, namespace?
I tried things like
content.document.getElementsByName('flvplayer').item(0)
Using Pentadactyls JS intepreter (accessed with :js)
This does seem to give me the player handle, or at least it prints out a <html:object> which corresponds to it.
Appending a .play() to it doesn't work, though. It's not a function.
What do I need to do to emulate the Web-Consoles way of doing it?
I realize that this might be a very spoonfeedy question, so if that is not acceptable then I'd still appreciate to get pointed into directions where I could possibly discover the solution myself by reading.
I tried searching for it myself but the terms seem to be quite ambiguous and I usually get results with people talking about their own sites, with scripts running inside of that 'namespace', not from outside like I am trying to do.
(Unless I am wrong about the concepts of inside and outside here.)
Cheers~~
The following command works for me; it defines the command ypl which
plays the YouTube video on the page
command! ypl open javascript:(function()
{content.document.getElementById('movie_player').playVideo()})()
Another example: this defines the ytr command which takes an integer argument and moves the current time position of the video by that amount in seconds
command! -nargs=1 ytr open javascript:(function(){var vid =
content.document.getElementById('movie_player'); vid.seekTo(vid.getCurrentTime() +
(<args>), true)})()
I hope that helps a bit. When I wrote those a while ago I may have tried :js and if it didn't work used :open javascript:....

Google Maps V3 not loading (Asked & Answered)

This question is already answered. I discovered what the problem is.
But, I'm posting the Q&A here because others may be in the same predicament.
My google map code came from samples I found on the web.
In the "bad" code there was a line that looked like this:
var latlng= new google.maps.LatLng(results[0].geometry.location.Ua, results[0].geometry.location.Va);
This code worked until last night.
Using firebug to inspect the objects, it turns out that location is now of the form: {Ta: number, Ua: number}
My immediate fix was to use the lat() and lng() methods whenever I required the lat and/or lng.
The other fix was to instantiate my map in a more intelligent fashion.
Yes, it was silly rely upon properties uncovered deep in an object using the firebug inspector. Yes, being a google maps noob and relying on copy paste with little or no knowledge reaped its just rewards.
But, doing a quick google seach found many folks (other than the "sample" I borrowed from) also using the .Va property directly.
Hence the post here in case this is their problem too.
In case you're interested in why this happened, it's simple: the sample was using undocumented internals of the API, so when Google updated the Maps JS file, it broke.
More specifically, Ua and Va were auto-generated variable names resulting from minification. It looks like Google removed a variable in the original source and the labels shifted up (Ua,Va → Ta,Ua).
I'll bet I know exactly how the author of the bad sample came up with his code. He inspected a LatLng (the type of object in location in your example) in his browser's dev tools, saw that those two oddly-named variables contained the data he wanted, and just went with it. Since the lat and lng methods are "hidden" in LatLng's prototype, he didn't notice them.
There are two lessons to be learned here:
Always use documented API methods; anything else is an implementation detail that is subject to change.
Don't trust the code on some dude's website is a good or even competent example of how to do things. This is especially true in the case of Google Maps, where there's extensive documentation and official examples.

Categories

Resources