Opened 12 years ago

Closed 12 years ago

#4254 closed defect (fixed)

Mail demo: list of messages sometimes blank (IE7)

Reported by: bill Owned by: bill
Priority: high Milestone: 1.0
Component: Dijit Version: 0.9
Keywords: mail Cc:
Blocked By: Blocking:

Description

Not sure if this is a dojo.data bug or something else. On IE7 the list of messages is sometimes originally blank when first displaying the page. (Refresh the page a few times to see it) Probably a race condition with whether the table widget calls fetch() before the data has finished downloading?

See example: http://archive.dojotoolkit.org/dojo-2007-08-20/dojotoolkit/dijit/demos/mail.html

Change History (12)

comment:1 Changed 12 years ago by Jared Jurkiewicz

Bill,

Unlikely a problem with dojo.data. The data doesn't download *until* the first fetch for ItemFileReadStore?. It's the first fetch that triggers the retrieval.

comment:2 Changed 12 years ago by Jared Jurkiewicz

In fact, I pulled down that nightly build and ran the demo locally. I can reproduce the problem, but it doesn't appear to be in dojo.data.

Here's what I did:

1.) Opened dijit/demos/Mail.html and set the to LayoutContainer? to height 50%, so the debug console could be seen.

2.) Modified ItemFileReadStore? to emit when fetch is called, the query, and the number of items returned. I also have it dump the label.

Results:

1.) First load with a clear cache (messages list displays fine):

Output from dojo.data: Normal flow:

Invoking FETCH with query: {"type": "folder"} Invoking FETCH with query: {"type": "address"} Invoking FETCH with query: {"type": "message"} Invoking onComplete callback with item count: 1 Item identified: [Mail Folders] Invoked onComplete callback with item count: 1 Invoking onComplete callback with item count: 3 Item identified: [Adam Arlen] Item identified: [Bob Baxter] Item identified: [Carrie Crow] Invoked onComplete callback with item count: 3 Invoking onComplete callback with item count: 20 Item identified: [congratulations] Item identified: [lunch] Item identified: [lunch] Item identified: [lunch] Item identified: [lunch] Item identified: [paint] Item identified: [paint] Item identified: [paint] Item identified: [paint] Item identified: [paint] Item identified: [remaining work] Item identified: [remaining work] Item identified: [remaining work] Item identified: [remaining work] Item identified: [schedule] Item identified: [today's meeting] Item identified: [today's meeting] Item identified: [today's meeting] Item identified: [today's meeting] Item identified: [today's meeting] completed tbody Invoked onComplete callback with item count: 20

Second load through reload of page, no cache clear (messages table shows up empty): Output from dojo.data: Invoking FETCH with query: {"type": "folder"} Invoking onComplete callback with item count: 1 Item identified: [Mail Folders] Invoked onComplete callback with item count: 1 Invoking FETCH with query: {"type": "address"} Invoking onComplete callback with item count: 3 Item identified: [Adam Arlen] Item identified: [Bob Baxter] Item identified: [Carrie Crow] Invoked onComplete callback with item count: 3 Invoking FETCH with query: {"type": "message"} Invoking onComplete callback with item count: 20 Item identified: [congratulations] Item identified: [lunch] Item identified: [lunch] Item identified: [lunch] Item identified: [lunch] Item identified: [paint] Item identified: [paint] Item identified: [paint] Item identified: [paint] Item identified: [paint] Item identified: [remaining work] Item identified: [remaining work] Item identified: [remaining work] Item identified: [remaining work] Item identified: [schedule] Item identified: [today's meeting] Item identified: [today's meeting] Item identified: [today's meeting] Item identified: [today's meeting] Item identified: [today's meeting] completed tbody Invoked onComplete callback with item count: 20

In both cases the dojo.data fetch calls do return data and invoke the callbacks passed as the onComplete parameter of the request object.

Ergo, I have to deduce that there is a timing issue in the application rendering flow, not specifically in dojo.data.

Routing this back to dijit.

comment:3 Changed 12 years ago by Jared Jurkiewicz

Component: DataDijit
Owner: Jared Jurkiewicz deleted

comment:4 Changed 12 years ago by Jared Jurkiewicz

Owner: set to bill

comment:5 Changed 12 years ago by Jared Jurkiewicz

I think your invoke fetch may be occuring before the table widget has been completely initialized, or something. From what I can tell, dojo.data is properly finding and returning items through the onComplete callback. What the demo does with those items, I do not know.

comment:6 Changed 12 years ago by Jared Jurkiewicz

I also just put in debug into the onITem callback handling, since I noticed you were also using it. Same results as with onComplete, really.

Looking at onItem flow well: Cache clear in IE 7 (loads and displays fine): Invoking FETCH with query: {"type": "folder"} Invoking FETCH with query: {"type": "address"} Invoking FETCH with query: {"type": "message"} Invoking onComplete callback with item count: 1 Invoked onComplete callback with item count: 1 Invoking onComplete callback with item count: 3 Invoked onComplete callback with item count: 3 onItem invoke begin onItem invoked on item with label: [congratulations] onItem invoked on item with label: [lunch] onItem invoked on item with label: [lunch] onItem invoked on item with label: [lunch] onItem invoked on item with label: [lunch] onItem invoked on item with label: [paint] onItem invoked on item with label: [paint] onItem invoked on item with label: [paint] onItem invoked on item with label: [paint] onItem invoked on item with label: [paint] onItem invoked on item with label: [remaining work] onItem invoked on item with label: [remaining work] onItem invoked on item with label: [remaining work] onItem invoked on item with label: [remaining work] onItem invoked on item with label: [schedule] onItem invoked on item with label: [today's meeting] onItem invoked on item with label: [today's meeting] onItem invoked on item with label: [today's meeting] onItem invoked on item with label: [today's meeting] onItem invoked on item with label: [today's meeting] onItem invoke end Invoking onComplete callback with item count: 20 completed tbody Invoked onComplete callback with item count: 20

Reload (message list empty): Invoking FETCH with query: {"type": "folder"} Invoking onComplete callback with item count: 1 Invoked onComplete callback with item count: 1 Invoking FETCH with query: {"type": "address"} Invoking onComplete callback with item count: 3 Invoked onComplete callback with item count: 3 Invoking FETCH with query: {"type": "message"} onItem invoke begin onItem invoked on item with label: [congratulations] onItem invoked on item with label: [lunch] onItem invoked on item with label: [lunch] onItem invoked on item with label: [lunch] onItem invoked on item with label: [lunch] onItem invoked on item with label: [paint] onItem invoked on item with label: [paint] onItem invoked on item with label: [paint] onItem invoked on item with label: [paint] onItem invoked on item with label: [paint] onItem invoked on item with label: [remaining work] onItem invoked on item with label: [remaining work] onItem invoked on item with label: [remaining work] onItem invoked on item with label: [remaining work] onItem invoked on item with label: [schedule] onItem invoked on item with label: [today's meeting] onItem invoked on item with label: [today's meeting] onItem invoked on item with label: [today's meeting] onItem invoked on item with label: [today's meeting] onItem invoked on item with label: [today's meeting] onItem invoke end Invoking onComplete callback with item count: 20 completed tbody Invoked onComplete callback with item count: 20

Though I noticed that items array was being passed when onComplete was set, which is wrong and a bug that needs to be fixed. I thought I had specific tests for that. I'll have to check the UT for ItemFileReadStore? to see if they were inavertantly removed.

comment:7 Changed 12 years ago by Jared Jurkiewicz

Now, I tried hacking into your store demo, particilarly the onItem callback you attach to.

With cache cleared (messages display fine), I get: Invoking FETCH with query: {"type": "folder"} Invoking FETCH with query: {"type": "address"} Invoking FETCH with query: {"type": "message"} Invoking onComplete callback with items count: 1 Invoked onComplete callback Invoking onComplete callback with items count: 3 Invoked onComplete callback onItem invoke begin In onItem handling. In onItem cloned tr node: [object] Doing a forEach on the item for attribute: sender and value was: Rob Raxter Doing a forEach on the item for attribute: label and value was: congratulations Doing a forEach on the item for attribute: sent and value was: 2005-12-18 Appending updated tr In onItem handling. In onItem cloned tr node: [object] Doing a forEach on the item for attribute: sender and value was: Carrey Crown Doing a forEach on the item for attribute: label and value was: lunch Doing a forEach on the item for attribute: sent and value was: 2005-12-17 Appending updated tr In onItem handling. In onItem cloned tr node: [object] Doing a forEach on the item for attribute: sender and value was: Bob Baxter Doing a forEach on the item for attribute: label and value was: lunch Doing a forEach on the item for attribute: sent and value was: 2005-12-17 Appending updated tr In onItem handling. In onItem cloned tr node: [object] Doing a forEach on the item for attribute: sender and value was: Jack Jackson Doing a forEach on the item for attribute: label and value was: lunch Doing a forEach on the item for attribute: sent and value was: 2005-12-17 Appending updated tr In onItem handling. In onItem cloned tr node: [object] Doing a forEach on the item for attribute: sender and value was: Jill Jones Doing a forEach on the item for attribute: label and value was: lunch Doing a forEach on the item for attribute: sent and value was: 2005-12-17 Appending updated tr In onItem handling. In onItem cloned tr node: [object] Doing a forEach on the item for attribute: sender and value was: David Davis Doing a forEach on the item for attribute: label and value was: paint Doing a forEach on the item for attribute: sent and value was: 2005-12-16 Appending updated tr In onItem handling. In onItem cloned tr node: [object] Doing a forEach on the item for attribute: sender and value was: Daniel Dooey Doing a forEach on the item for attribute: label and value was: paint Doing a forEach on the item for attribute: sent and value was: 2005-12-16 Appending updated tr In onItem handling. In onItem cloned tr node: [object] Doing a forEach on the item for attribute: sender and value was: Bob Baxter Doing a forEach on the item for attribute: label and value was: paint Doing a forEach on the item for attribute: sent and value was: 2005-12-16 Appending updated tr In onItem handling. In onItem cloned tr node: [object] Doing a forEach on the item for attribute: sender and value was: Jack Jackson Doing a forEach on the item for attribute: label and value was: paint Doing a forEach on the item for attribute: sent and value was: 2005-12-16 Appending updated tr In onItem handling. In onItem cloned tr node: [object] Doing a forEach on the item for attribute: sender and value was: Jill Jones Doing a forEach on the item for attribute: label and value was: paint Doing a forEach on the item for attribute: sent and value was: 2005-12-16 Appending updated tr In onItem handling. In onItem cloned tr node: [object] Doing a forEach on the item for attribute: sender and value was: Bob Baxter Doing a forEach on the item for attribute: label and value was: remaining work Doing a forEach on the item for attribute: sent and value was: 2005-12-18 Appending updated tr In onItem handling. In onItem cloned tr node: [object] Doing a forEach on the item for attribute: sender and value was: Bob Baxter Doing a forEach on the item for attribute: label and value was: remaining work Doing a forEach on the item for attribute: sent and value was: 2005-12-18 Appending updated tr In onItem handling. In onItem cloned tr node: [object] Doing a forEach on the item for attribute: sender and value was: Jack Jackson Doing a forEach on the item for attribute: label and value was: remaining work Doing a forEach on the item for attribute: sent and value was: 2005-12-18 Appending updated tr In onItem handling. In onItem cloned tr node: [object] Doing a forEach on the item for attribute: sender and value was: Jill Jones Doing a forEach on the item for attribute: label and value was: remaining work Doing a forEach on the item for attribute: sent and value was: 2005-12-18 Appending updated tr In onItem handling. In onItem cloned tr node: [object] Doing a forEach on the item for attribute: sender and value was: Carrie Crow Doing a forEach on the item for attribute: label and value was: schedule Doing a forEach on the item for attribute: sent and value was: 2005-12-17 Appending updated tr In onItem handling. In onItem cloned tr node: [object] Doing a forEach on the item for attribute: sender and value was: Adam Arlen Doing a forEach on the item for attribute: label and value was: today's meeting Doing a forEach on the item for attribute: sent and value was: 2005-12-19 Appending updated tr In onItem handling. In onItem cloned tr node: [object] Doing a forEach on the item for attribute: sender and value was: Madam Marlen Doing a forEach on the item for attribute: label and value was: today's meeting Doing a forEach on the item for attribute: sent and value was: 2005-12-19 Appending updated tr In onItem handling. In onItem cloned tr node: [object] Doing a forEach on the item for attribute: sender and value was: Bob Baxter Doing a forEach on the item for attribute: label and value was: today's meeting Doing a forEach on the item for attribute: sent and value was: 2005-12-19 Appending updated tr In onItem handling. In onItem cloned tr node: [object] Doing a forEach on the item for attribute: sender and value was: Jack Jackson Doing a forEach on the item for attribute: label and value was: today's meeting Doing a forEach on the item for attribute: sent and value was: 2005-12-19 Appending updated tr In onItem handling. In onItem cloned tr node: [object] Doing a forEach on the item for attribute: sender and value was: Jill Jones Doing a forEach on the item for attribute: label and value was: today's meeting Doing a forEach on the item for attribute: sent and value was: 2005-12-19 Appending updated tr onItem invoke end Invoking onComplete callback with items null (onItem callback was used) completed tbody Invoked onComplete callback

Now, with cache NOT clear, I get something completely different in the emit. I get: Invoking FETCH with query: {"type": "folder"} Invoking onComplete callback with items count: 1 Invoked onComplete callback Invoking FETCH with query: {"type": "address"} Invoking onComplete callback with items count: 3 Invoked onComplete callback Invoking FETCH with query: {"type": "message"} onItem invoke begin In onItem handling. In onItem cloned tr node: [object] Appending updated tr In onItem handling. In onItem cloned tr node: [object] Appending updated tr In onItem handling. In onItem cloned tr node: [object] Appending updated tr In onItem handling. In onItem cloned tr node: [object] Appending updated tr In onItem handling. In onItem cloned tr node: [object] Appending updated tr In onItem handling. In onItem cloned tr node: [object] Appending updated tr In onItem handling. In onItem cloned tr node: [object] Appending updated tr In onItem handling. In onItem cloned tr node: [object] Appending updated tr In onItem handling. In onItem cloned tr node: [object] Appending updated tr In onItem handling. In onItem cloned tr node: [object] Appending updated tr In onItem handling. In onItem cloned tr node: [object] Appending updated tr In onItem handling. In onItem cloned tr node: [object] Appending updated tr In onItem handling. In onItem cloned tr node: [object] Appending updated tr In onItem handling. In onItem cloned tr node: [object] Appending updated tr In onItem handling. In onItem cloned tr node: [object] Appending updated tr In onItem handling. In onItem cloned tr node: [object] Appending updated tr In onItem handling. In onItem cloned tr node: [object] Appending updated tr In onItem handling. In onItem cloned tr node: [object] Appending updated tr In onItem handling. In onItem cloned tr node: [object] Appending updated tr In onItem handling. In onItem cloned tr node: [object] Appending updated tr onItem invoke end Invoking onComplete callback with items null (onItem callback was used) completed tbody Invoked onComplete callback

Note that it never enters the forEach() call.

The problem is somewhere in this script tag:

<script type="dojo/method" event="onItem" args="item">

console.log("In onItem handling.");

var tr = this.row.cloneNode(true);

console.log("In onItem cloned tr node: " + tr);

dojo.query("td", tr).forEach(function(n, i, a){

console.log("Doing a forEach on the item for attribute: " + this.columns[i].attribute + " and value was: " + this.store.getValue(item, this.columns[i].attribute)
"");
n.innerHTML = this.store.getValue(item, this.columns[i].attribute)
"";

}, this);

console.log("Appending updated tr");

this.body.appendChild(tr); var _self = this; dojo.connect(tr, "onclick", this, function(){ _self.onClick(item); });

</script>

My guess is the dojo query is returning an empty nodeset.

comment:8 Changed 12 years ago by bill

Owner: changed from bill to alex

Alex, can you take a look? The query is triggered in postCreate() so the DOM node should already be attached to the tree, so I'm not sure why dojo.query() would be failing, but anyway it's worth some investigation.

comment:9 Changed 12 years ago by Jared Jurkiewicz

Further info. Fumped in debug on emitting nodeste size:

Cache cleared, first load: ... Appending updated tr In onItem handling. In onItem cloned tr node: [object] Number is set is: 3 Doing a forEach on the item for attribute: sender and value was: Jack Jackson Doing a forEach on the item for attribute: label and value was: lunch Doing a forEach on the item for attribute: sent and value was: 2005-12-17 ....

Page refresh behavior: In onItem handling. In onItem cloned tr node: [object] Number is set is: 0 Appending updated tr In onItem handling.

So dojo.query is definitely returning 0 on subsequent refreshes after initial load.

comment:10 Changed 12 years ago by Adam Peller

perhaps related to #4218, which is failing in the same place

comment:11 Changed 12 years ago by bill

Owner: changed from alex to bill
Status: newassigned

It's due to a race condition; the query is starts in postCreate(), but processing the query results depends on data setup in the postscript, as declared by

<script type="dojo/method">

It sometimes works due to the delay in executing the query: ie, it works if the postscript executes before the query returns.

comment:12 Changed 12 years ago by bill

Resolution: fixed
Status: assignedclosed

(In [11104]) Fixes #4254: fix race condition between when postscript runs and when the query result returns

Note: See TracTickets for help on using tickets.