FNCGGrid LoadFromCSVStream limit w/ Web Core

Hi!

I'm using streams, and I get:
Uncaught RangeError: Maximum call stack size exceeded | RangeError: Maximum call stack size exceeded at Object.LoadFromStream$1 (http://localhost:8000/ ... .js:19428:34) at Object.InputFromCSVStream (http://localhost:8000/ ... .js:169753:51) at Object.LoadFromCSVStream

It seems to be more a size issue than an encoding issue. Everything works fine while the data is not so big. I could not use TEncoding.Unicode as in that previous topic because of some other charset issue (Browser throws Failed to execute 'btoa' on 'Window': The string to be encoded contains characters outside of the Latin1 range)

Is there anything new or any other workaround about this kind of size limit ?

In weblib.FNCxxx aren't there any procedure/function/event calls inherited from VCL FNC units that behave asynchronously in web framework, so that they could cause this call stack overflow when data become bigger? Other kind of recursive calls that could be very data-size sensible?

Please define which size the file is you are trying to load?

The grid has 31 columns (+1 fixed with no data).

43KB, 68 rows Ok.
229KB, 396 rows Ok.
271KB, 464 rows: Uncaught RangeError: Maximum call stack size exceeded at Object.LoadFromStream$1 , at Object.InputFromCSVStream .

It's not a file. It's a TStringStream I'm loading from.

procedure TForm4.btnLoadStream2800Click(Sender: TObject);
var
  tmpSL: TStringList;
  tmpStream: TStringStream;
begin
  tmpSL := TStringList.Create;
  tmpSL.LoadFromFile('Test2800.csv');

  tmpStream := TStringStream.Create(tmpSL.Text);
  tmpStream.Position := 0;

  Grid.LoadFromCSVStream(tmpStream, TEncoding.Unicode);

  tmpSL.Free;
  tmpStream.Free;
end;
    x := TJSObject(Response.Result);
    sConvert := window.atob(TJSString(TJSObject(x['Resultado'])['GridData']).ValueOf);
    stGridData     := TStringStream.Create(sConvert);
    txtStatus.Text := txtStatus.Text + ' (' + FormatFloat('#,##0.00', stGridData.Size / 1000) + 'KB)';
    grd.IOOffset := Point(1, 0);
    stGridData.Position := 0;
    grd.LoadFromCSVStream(stGridData);
    stGridData.Free;

This is my Web Core code. Microsoft Edge. Runs ok with few data. Do you want me to prepare a file with my stream content?

Check the code above, please add TEncoding.Unicode, we have tested a CSV file with 2800 rows.

it's beign generated this way:

  AGrid.SaveHiddenCells := False;
  AGrid.IOOffset := Point(1, 0);
  st := TStringStream.Create('');
  AGrid.SaveToCSVStream(st);
  st.Position := 0;
  stOut := TStringStream.Create('');
  stOut.Position := 0;
  TNetEncoding.Base64.Encode(st, stOut);
  FGridData := stOut.DataString;
  stOut.Free;
  st.Free;

When I tried to follow what you said in that former topic (in that case, a file, not stream) and used Unicode at both sides , I got an error from Edge when loading the stream: Failed to execute 'btoa' on 'Window': The string to be encoded contains characters outside of the Latin1 range.

Also for saving you need to pass along the encoding parameter.

Now I changed it to Unicode again.

I wasn't passing for loading.

I noticed that at the first time I tried it, I've created the stream as Unicode, but didn't put Encoding.Unicode when calling LoadFromCSVStream.

Now I could load 4MB. Thanks !

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.