Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Maximum call stack size exceeded error when grouping a grid

    SmartGWT LGPL 6.0p, nightly build 2018-01-03, SmartClient Version: v11.0p_2018-01-03/LGPL Development Only (built 2018-01-03)

    When grouping a ListGrid configured with setFilterLocalData(true) with a field, an endless loop is encountered and the browser throws a "Maximum call stack size exceeded" error (in Chrome). It seems that the error is thrown (at least) with the first grouping which is done.

    Code:
    RangeError: Maximum call stack size exceeded
    Stack from error.stack:
        cons.getTotalRows(<no args: exited>) on[ListGrid ID:isc_ListGrid_0] @ ListGrid.js:40132:31
        cons.dataChanged(<no args: exited>) on[ListGrid ID:isc_ListGrid_0] @ ListGrid.js:16407:24
        cons.<anonymous>(<no args: exited>) on[ListGrid ID:isc_ListGrid_0] @ ListGrid.js:15659:35
        cons.observation(<no args: exited>) on [ResultSet ID:isc_ResultSet_1(dataSource: myDS, created directly)] @ Class.js:2554:28
        cons._doneChangingData(<no args: exited>) on [ResultSet ID:isc_ResultSet_1(dataSource: myDS, created directly)] @ ResultSet.js:2968:14
        cons.filterLocalData(<no args: exited>) on [ResultSet ID:isc_ResultSet_1(dataSource: myDS, created directly)] @ ResultSet.js:4245:28
        cons.dataChanged(<no args: exited>) on[ListGrid ID:isc_ListGrid_0] @ ListGrid.js:16296:22
        cons.groupBy(<no args: exited>) on[ListGrid ID:isc_ListGrid_0] @ ListGrid.js:50038:10
        cons.setGroupSpecifiers(<no args: exited>) on[ListGrid ID:isc_ListGrid_0] @ ListGrid.js:49851:14
        cons.groupBy(<no args: exited>) on[ListGrid ID:isc_ListGrid_0] @ ListGrid.js:49944:18
        cons.dataChanged(<no args: exited>) on[ListGrid ID:isc_ListGrid_0] @ ListGrid.js:16322:14
        cons.groupBy(<no args: exited>) on[ListGrid ID:isc_ListGrid_0] @ ListGrid.js:50038:10
        cons.setGroupSpecifiers(<no args: exited>) on[ListGrid ID:isc_ListGrid_0] @ ListGrid.js:49851:14
        cons.groupBy(<no args: exited>) on[ListGrid ID:isc_ListGrid_0] @ ListGrid.js:49944:18
        cons.dataChanged(<no args: exited>) on[ListGrid ID:isc_ListGrid_0] @ ListGrid.js:16322:14
        cons.groupBy(<no args: exited>) on[ListGrid ID:isc_ListGrid_0] @ ListGrid.js:50038:10
        cons.setGroupSpecifiers(<no args: exited>) on[ListGrid ID:isc_ListGrid_0] @ ListGrid.js:49851:14
        cons.groupBy(<no args: exited>) on[ListGrid ID:isc_ListGrid_0] @ ListGrid.js:49944:18
        cons.dataChanged(<no args: exited>) on[ListGrid ID:isc_ListGrid_0] @ ListGrid.js:16322:14
        ...
    Reproducible with the following code:

    Code:
        public void doOnModuleLoad() {
            viewport = new VLayout();
            viewport.setWidth100();
            viewport.setHeight100();
            viewport.setOverflow(Overflow.HIDDEN);
    
            final DataSource ds = new DataSource();
            ds.setID("myDS");
            DataSourceIntegerField f1 = new DataSourceIntegerField("f1");
            f1.setPrimaryKey(true);
            f1.setHidden(true);
            DataSourceTextField f2 = new DataSourceTextField("f2");
            DataSourceIntegerField f3 = new DataSourceIntegerField("f3");
            HashMap vm = new HashMap();
            vm.put(0, "first val");
            vm.put(1, "second val");
            f3.setValueMap(vm);
            ds.setFields(f1, f2, f3);
            ds.setClientOnly(true);
    
            ListGridRecord[] recs = new ListGridRecord[999];
            for(int i=0; i<999; i++) {
                final ListGridRecord r = new ListGridRecord();
                r.setAttribute("f1", "" + i);
                r.setAttribute("f2", i + " value");
                r.setAttribute("f3", i % 0);
                recs[i] = r;
            }
            ds.setTestData(recs);
    
            final ListGrid g = new ListGrid();
            g.setDataSource(ds);
    
            g.setCanGroupBy(true);
            // if set, first grouping of the grid goes to endless loop and throws "maximum call stack exceeded" (in chrome)
            g.setFilterLocalData(true);
    
            ListGridField gf1 = new ListGridField("f1");
            ListGridField gf2 = new ListGridField("f2");
            ListGridField gf3 = new ListGridField("f3");
            g.setFields(gf1, gf2, gf3);
    
            final Criteria fetchCriteria = new Criteria();
            ds.fetchData(fetchCriteria, new DSCallback() {
                @Override
                public void execute(DSResponse dsResponse, Object data, DSRequest dsRequest) {
                    ResultSet resultSet = new ResultSet(ds);
                    resultSet.setAllRows(dsResponse.getData());
                    resultSet.setCriteria(fetchCriteria);
                    g.setData(resultSet);
                }
            });
    
            viewport.addMember(g);
            viewport.draw();
    
            SC.showConsole();
        }
    To reproduce, run the following code, group the field with some field (for example field "f2") and observe, that the grouping takes a while by freezing the browser and the console is printed with the stack error.

    #2
    This has been fixed back to SGWT 5.1p/SC 10.1p and the fix will be in the nightly builds dated 2018-01-09 and beyond.

    Comment


      #3
      Thanks, I can confirm the problem is now fixed.

      Comment

      Working...
      X