Select to view content in your preferred language

Print task error "Uncaught RangeError:  Maximum call stack size exceeded"

5075
17
Jump to solution
07-23-2012 03:11 PM
SharathNarasimhan
Deactivated User
I am trying to use the Print task for printing out map with highlighted feature layers which is basically the results of a Find task. The Print task works fine before performing the Find task but just return an error on the browser console as "Uncaught RangeError: Maximum call stack size exceeded - esri._sanitize" when some of the features in the map are highlighted. I am currently using ArcGIS server 10.1 edition along with ArcGIS javascript 3.0 APIs.

Any suggestions on this. ?
0 Kudos
17 Replies
derekswingley1
Deactivated User
Were you able to try my suggestion of using dojo.clone inside of your callback to dojo.map?
0 Kudos
by Anonymous User
Not applicable
Hi Derek,

Sorry, your post regarding the clone only showed up this morning. Our proxy must've served an older version of it 😞

You're a champion. The one line you provided fixed our issue. Thanks very much. Yes, there are a lot of NULL attributes in the data, which have caused issues in other areas of our apps as well and had no idea that they'd interfere with the printing. Most, if not all our underlying data for our services will have NULLs in some fields of the data (frustrates the bejebus out of me).

Once again, thanks for all your attention and help in this matter. Much appreciated.
0 Kudos
SharathNarasimhan
Deactivated User
Hello Derek and Ingrid,

Sorry about not catching up on this thread. Your discussions have revealed several insights to this problem. Thanks a lot for that.

Derek,



I tried implementing your code fix  without any luck !
 
var items = dojo.map(results, function (result) {
  var graphic = result.feature;
  var sms = esri.symbol.SimpleMarkerSymbol;
  var sls = esri.symbol.SimpleLineSymbol;
  graphic.setSymbol(
    new sms(
      "circle", 
      14,
      new sls("solid", new dojo.Color([6, 105, 140]), 1), 
      new dojo.Color([6, 105, 140, 0.5])
    )
  );
  app.map.graphics.add(graphic);
  return dojo.clone(graphic.attributes);
});




The underlying print code in the JS API processes all map layers (including graphics) to remove object properties that are undefined or null (two reasons for this:  it's a waste to send properties that are undefined or null and the print service doesn't handle those types of values elegantly). When the JS API print code tries to process the graphic's attributes after they've been put through Dojo's store creation process it gets into an infinite loop somewhere. I haven't completely figured out the details on this, but it's definitely the source of your error.



I think my situation is similar to Ingrid here, wherein there are a lot of NULL attributes in the data. I am completely confused about this right now, please help me out on these queries:
Will these NULL attributes affect the print code of the JS API only when they are present in results ?  (I think this might not be the case since I have removed NULL attributes for the retrieved data and still encountered the same error)
Does the print code consider the data attributes of all the layers of the map ? (Although the print code works fine when no graphics are selected)

Your help in this is much appreciated. Thanks in advance.
0 Kudos
derekswingley1
Deactivated User

I think my situation is similar to Ingrid here, wherein there are a lot of NULL attributes in the data. I am completely confused about this right now, please help me out on these queries:
Will these NULL attributes affect the print code of the JS API only when they are present in results ?  (I think this might not be the case since I have removed NULL attributes for the retrieved data and still encountered the same error)
Does the print code consider the data attributes of all the layers of the map ? (Although the print code works fine when no graphics are selected)


Ingrid's situation was complicated by the fact that an ItemFileReadStore was being created using esri.Graphic.attributes objects. The ItemFileReadStore was modifying the structure of esri.Graphic.attributes and that, along with many null values, was causing the problem.

In Ingrid's case, we were able to get to a solution relatively quickly because code to reproduce was posted. Can you post some code to repro your issue?
0 Kudos
SharathNarasimhan
Deactivated User
Sorry about my previous comment. Your solution does work when we clone the graphic objects which are added to the ItemFileReadStore. I had failed to use the cloned objects. 🙂

Thanks a ton Derek !
0 Kudos
derekswingley1
Deactivated User
Glad to help and glad you got it figured out.
0 Kudos
AdrianMarsden
Honored Contributor
Hi Derek

I've got similar issues - I tweak one of my showresults functions like this
        var Findsymbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID,          new dojo.Color([98, 194, 204]), 2), new dojo.Color([98, 194, 204, 0.5]));
        var items = dojo.map(results, function (result) {
            var graphic = result.feature;
            graphic.setSymbol(Findsymbol);
            map.graphics.add(graphic);
            return dojo.clone(graphic.attributes);
            //return result.feature.attributes;
        });


This worked fine with fixing the stack overflow on print, however, as I had an onclick that went to the feature, that then broke.



function onRowClickHandlerLS(evt) {
    var clickedFeature = gridx.getItem(evt.rowIndex).OBJECTID;
    var selectedFeature;
    dojo.forEach(map.graphics.graphics, function (graphic) {
        if ((graphic.attributes) && graphic.attributes.OBJECTID === clickedFeature) {
            selectedFeature = graphic;
            return;
        }
    });
    var FeatureExtent = selectedFeature.geometry.getExtent();
    map.setExtent(FeatureExtent);
}

"Uncaught TypeError: Cannot read property 'geometry' of undefined "





Any ideas?  I'm having a good look at the moment but haven't seen anything obvious.

Cheers

ACM

Edit - it looks like either the graphic.attribute.OBJECTID or cthe row OBJECTID was not getting returned in the same type as it used to.  I have modified the onclick routine so -
function onRowClickHandlerLS(evt) {
    var clickedFeature = gridx.getItem(evt.rowIndex).OBJECTID;
    var selectedFeature;
    dojo.forEach(map.graphics.graphics, function (graphic) {
        var n1 = graphic.attributes.OBJECTID.toString();
        var n2 = clickedFeature.toString();
       
        if ((graphic.attributes) && n1 === n2) {
            console.debug("..." + n1 + "..." + n2 + "...")
            selectedFeature = graphic;
            return;
        }
    });
    var FeatureExtent = selectedFeature.geometry.getExtent();
    map.setExtent(FeatureExtent);
}


and all is well (on that one, I've another task that puts results into a grid that works different that I'm having issues with - more later, maybe, if I can't sort it)
0 Kudos
EmilyLaMunyon
Deactivated User
Hello,
I am having the same issue, where selected graphics do not show up when the map is printed, however, using dojo.clone works in a situation like this:
 dojo.forEach(response,function(result){
               var feature = result.feature;
               feature.setSymbol(markerSymbol);
               map.graphics.add(feature);
         return dojo.clone(feature.attributes);

However, when I use the dojo.clone, it seems like the ID is not being passed and my datagrid and zoom to functions are broken. Does anyone have ideas on how to fix this?

Thanks for any advice!
0 Kudos