Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 429741

Summary: [TableViewer] Javascript error in IE8
Product: [RT] RAP Reporter: Oliver B. <oliver>
Component: RWTAssignee: Project Inbox <rap-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P2 CC: ivan, tbuschto
Version: 2.2   
Target Milestone: 2.3 M3   
Hardware: All   
OS: All   
Whiteboard:

Description Oliver B. CLA 2014-03-06 03:44:20 EST
A javascript errors occurs in IE8 by filtering a TableViewer:
"Error: 'this.getRootItem()' ist Null oder kein Objekt"

Steps to reproduce:
(http://rap.eclipsesource.com/demo/release/rapdemo/examples#tableviewer)

1. Set Filter to "hel"
2. Wait for filtering
3. Add "a" to the filter
4. The javascript error occurs
Comment 1 Tim Buschtoens CLA 2014-03-06 04:12:24 EST
I can't reproduce it, but I'm only emulating IE8 in IE11.

Here is what the response text that apparently crashes the client looks like:

{"head":{"requestCounter":6},"operations":[["destroy","w234"],["set","w104",{"itemCount":0,"itemMetrics":[[0,0,50,0,0,0,0],[1,50,50,0,0,0,0],[2,100,140,0,0,0,0],[3,240,180,0,0,0,0],[4,420,50,0,0,0,0],[5,470,50,0,0,0,0]]}]]}

Destroy the last item, set grid item count to 0. Nothing special.

Just form the error message I suspect Grid._updateScrollHeight, line:

      var itemsOffsetHeight = this.getRootItem().getOffsetHeight();

But the only way getRooItem() should ever return null (or something else than an item) is if the Grid has been disposed, so I don't get how this could ever happen. 

Ivan, if you can reproduce this, can you check if this already existed in older RAP versions?
Comment 2 Ivan Furnadjiev CLA 2014-03-06 04:19:51 EST
(In reply to Tim Buschtoens from comment #1)
> Ivan, if you can reproduce this, can you check if this already existed in
> older RAP versions?
It's reproducible for me with online nightly Examples demo and real IE8 in VM with WinXP. Will check older version and report.
Comment 3 Ivan Furnadjiev CLA 2014-03-06 05:26:38 EST
It crashes with RAP 2.0 too:
Could not process server response:

Error: 'this.getRootItem()' is null or not an object

  Script: {
"head": {
"requestCounter": 8
},
"operations": [ [ "destroy", "w144" ], [ "set", "w135", {
"itemCount": 0,
"itemMetrics": [ [ 0, 0, 50, 0, 0, 0, 0 ], [ 1, 50, 50, 0, 0, 0, 0 ], [ 2, 100, 140, 0, 0, 0, 0 ], [ 3, 240, 180, 0, 0, 0, 0 ], [ 4, 420, 50, 0, 0, 0, 0 ], [ 5, 470, 50, 0, 0, 0, 0 ] ],
"focusItem": null
} ] ]
}
  name: TypeError
  message: 'this.getRootItem()' is null or not an object
  number: -2146823281
  description: 'this.getRootItem()' is null or not an object
  Debug: on
  Request: {"head":{"requestCounter":7},"operations":[["set","w134",{"selectionStart":4,"selectionLength":0,"text":"hela"}],["set","w1",{"cursorLocation":[360,260]}],["notify","w134","Modify",{}]]}
  Phase: 5
Comment 4 Ivan Furnadjiev CLA 2014-04-09 10:10:19 EDT
This error comes from GridItem.js#getDefaultHeight where GridItem#getRootItem returns null. It seems that in IE8 GridItem.js#getDefaultHeight is called after the item is disposed.
Comment 5 Ivan Furnadjiev CLA 2014-04-11 02:22:55 EDT
This issue is really weird. I've managed to trace it to the method from where the difference between IE8 and other browsers come - GridItem#getChild. Under some specific circumstances IE return an object (GridItem) when element from *empty* array is requested. Some logging from GridItem#getChild:
console.log( "GridItem#getChild index: " + index );  // 0
console.log( "GridItem#getChild children.length: " + this._children.length );  // 0
console.log( "GridItem#getChild children[ index ]: " + this._children[ index ] ); // *not* undefined
console.log( "GridItem#getChild is: " + this._children[ index ].classname ); // rwt.widgets.GridItem
console.log( "GridItem#getChild is disposed: " + this._children[ index ].isDisposed() ); // true
Comment 6 Ivan Furnadjiev CLA 2014-04-11 05:42:21 EDT
Fixed with change https://git.eclipse.org/r/24831.