Error with google chrome 'cannot read property "document" of null'

1,394 views
Skip to first unread message

Josh

unread,
Sep 14, 2010, 5:45:55 PM9/14/10
to Google Visualization API
Hello Visualization API group,

I am hitting a very odd error using a couple of very basic core google
visualization charts.

Using the area, bar, column or line charts, whenever I reload the page
by a form submission (get or post) I get a error message 'cannot read
property "document" of null' instead of my expected chart. If I hit
reload, or go to the page directly from a url, the chart renders
fine.

My charting code is very simple:

google.load('visualization', '1', {'packages':['corechart']});
google.setOnLoadCallback(drawChart);
function drawChart() {

var data = new google.visualization.DataTable(
(my datatable json),
0.6
);

var chart = new
google.visualization.LineChart(document.getElementById('chart_div1'));
var params = {(some parameters)};
chart.draw(data, params);

I encounter the error right after chart.draw. Even if I delete the
contents of the parameter array, I still encounter the issue.

This error is not occurring in firefox 3.6.8, and is occurring
consistently on google chrome 6.0.472.53, both running on Ubuntu. I
have heard of others encountering the issue on safari, but have not
confirmed the issue there.

I have a consistent reproducer for chrome here:

https://pub.needlebase.com/actions/visualizer/V2Visualizer.do?domain=Disasters&thread=Disaster.Incident+Start+Month^&typeId=8946670875749132661&render=Chart&chartSort=&selectedChart=LineChart&colIds=_Type&startPage=1&actionType=&targetParam=&messageJsp=&query=&queryDescription=&folder=&advQuery=&showCheckboxes=false&lastQueryName=&ownerOnly=

(note that in about a week, we may deploy a workaround that simply
refreshes the page if we encounter an error).

What makes this issue particularly odd, is that it does not always
occur. We have a number of different 'domains of data'. In the
Disasters domain that I linked above, the issue consistently occurs
for anything that we try to chart in that domain. The issue does not
occur for other domains, even others served by the same machine.
Several other domains consistently exhibit this behavior with chrome,
while most domains do not.

Has anybody encountered this issue before? Searching for the error
text did not turn up much of use. It appears that we are hitting a js
exception deep within the charting code, and falling through to a
catch block.

Thank you for any assistance.

Josh Ain

Josh

unread,
Sep 14, 2010, 5:58:18 PM9/14/10
to Google Visualization API
Oh, and I think I used the wrong url for a reproducer. Here are more
details on reproducing the issue. In chrome, goto

https://pub.needlebase.com/actions/visualizer/V2Visualizer.do?domain=Disasters&thread=Hazard+Mitigation+Program^&typeId=9149585060559937610&render=Chart&chartSort=&selectedChart=LineChart&colIds=9149585060559937628&startPage=1&actionType=&targetParam=&messageJsp=&query=&queryDescription=&folder=&advQuery=&showCheckboxes=false&lastQueryName=&defaultTypeQuery=&ownerOnly=

Then, in the first select box in the upper left, change the value from
Disaster to _Batch. This will submit a form on the page, reload the
page, and reproduce the issue.

Josh
> https://pub.needlebase.com/actions/visualizer/V2Visualizer.do?domain=...&typeId=8946670875749132661&render=Chart&chartSort=&selectedChart=LineChart&colIds=_Type&startPage=1&actionType=&targetParam=&messageJsp=&query=&queryDescription=&folder=&advQuery=&showCheckboxes=false&lastQueryName=&ownerOnly=

Viz Kid

unread,
Sep 15, 2010, 10:09:20 AM9/15/10
to google-visua...@googlegroups.com

Can you possibly give a simpler example page where this happens?
Your current page is very complex and it would be impossible to follow.

In general, such errors might be result of race conditions when you load several things. Maybe you can load the visualization API only once instead of each operation?

Best,
  Viz Kid


--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To post to this group, send email to google-visua...@googlegroups.com.
To unsubscribe from this group, send email to google-visualizati...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-visualization-api?hl=en.


Josh Ain

unread,
Sep 15, 2010, 10:16:02 AM9/15/10
to google-visua...@googlegroups.com
Viz Kid,

Thank you for your response. I can't (thus far) reproduce the issue on
a simpler page. Even on this page, if I load different data, the issue
usually does not occur. The issue does consistently occur with any
data in this set of data, and four other sets of data (that do not
have any discernible similarities that I can see).

I am only loading the visualization api once on the page. I thought
that the issue might be a race condition, but I have debugged through
the js code (which should slow down any execution) and the issue still
consistently occurs.

Any other thoughts?

Josh Ain

Josh

unread,
Sep 15, 2010, 11:09:00 AM9/15/10
to Google Visualization API
Hmm... one more detail. Going off Viz Kid's thought that this was a
race condition, if I just insert a delay before drawing the chart,
things seem to work fine. I changed my onLoadCallback to:

google.setOnLoadCallback(setTimeout('drawChart()', 10));

and no longer see the problem. Is it possible that there is a timing
issue with the google.load function?

Josh

On Sep 15, 10:16 am, Josh Ain <josh....@gmail.com> wrote:
> Viz Kid,
>
> Thank you for your response. I can't (thus far) reproduce the issue on
> a simpler page. Even on this page, if I load different data, the issue
> usually does not occur. The issue does consistently occur with any
> data in this set of data, and four other sets of data (that do not
> have any discernible similarities that I can see).
>
> I am only loading the visualization api once on the page. I thought
> that the issue might be a race condition, but I have debugged through
> the js code (which should slow down any execution) and the issue still
> consistently occurs.
>
> Any other thoughts?
>
> Josh Ain
>
> On Wed, Sep 15, 2010 at 10:09 AM, Viz Kid <viz...@google.com> wrote:
>
> > Can you possibly give a simpler example page where this happens?
> > Your current page is very complex and it would be impossible to follow.
> > In general, such errors might be result of race conditions when you load
> > several things. Maybe you can load the visualization API only once instead
> > of each operation?
> > Best,
> >   Viz Kid
>
> > On Tue, Sep 14, 2010 at 11:58 PM, Josh <josh....@gmail.com> wrote:
>
> >> Oh, and I think I used the wrong url for a reproducer. Here are more
> >> details on reproducing the issue. In chrome, goto
>
> >>https://pub.needlebase.com/actions/visualizer/V2Visualizer.do?domain=...&typeId=9149585060559937610&render=Chart&chartSort=&selectedChart=LineChart&colIds=9149585060559937628&startPage=1&actionType=&targetParam=&messageJsp=&query=&queryDescription=&folder=&advQuery=&showCheckboxes=false&lastQueryName=&defaultTypeQuery=&ownerOnly=

Viz Kid

unread,
Sep 15, 2010, 11:13:39 AM9/15/10
to google-visua...@googlegroups.com

I'm happy that you found a solution.
It is not clear what causes the error but it is possible it is somehow related to the frame the chart is building for its drawing.

Hopefully we would be able to solve it in the future but for now it seems you have a workaround.

Best,
  Viz Kid
Reply all
Reply to author
Forward
0 new messages