Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

loadString() for big .txt files #2661

Closed
2 of 14 tasks
keiwanjamaly opened this issue Feb 23, 2018 · 10 comments
Closed
2 of 14 tasks

loadString() for big .txt files #2661

keiwanjamaly opened this issue Feb 23, 2018 · 10 comments
Assignees
Labels

Comments

@keiwanjamaly
Copy link

keiwanjamaly commented Feb 23, 2018

Most appropriate sub-area of p5.js?

  • Color
  • Core
  • Data
  • Events
  • Image
  • IO
  • Math
  • Typography
  • Utilities
  • WebGL
  • Other (specify if possible)

Which platform were you using when you encountered this?

  • Mobile/Tablet (touch devices)
  • Desktop/Laptop
  • Others (specify if possible)

This is my first Issue, so plase keep that in mind while reading it.
I tried to load in the preload() function a .txt file using the function loadString(). The Problem I get is, that in the browser it keeps saing Loading....
The output_coord_cartesian.txt is a large file and not loadable in the standart text editors. I think that loading the file just takes very very long in p5.js. If it is so, is there a way around this problem?

Here is my code... maybe it is a diffrent kind of problem
sketch.js:

var x;
var y;
var t = 0;
var file;


function setup() {
  createCanvas(400, 400);
}

function preload() {
  file = loadStrings("../output_coord_cartesian.txt");
  // also tried moving the file and then
  // file = loadStrings("output_coord_cartesian.txt");
}


function draw() {
  // some magic
}

and index.html:

<!DOCTYPE html>
<html>
  <head>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.6.0/p5.js"></script>
    <script src="./sketch.js"></script>
  </head>
  <body>
  </body>
</html>

Edit:
Smaller files work fine.

@Spongman
Copy link
Contributor

Did you try a smaller file?

@keiwanjamaly
Copy link
Author

Yes I just did. It seems to work fine.

@limzykenneth
Copy link
Member

limzykenneth commented Feb 23, 2018

@Bomel Can you open the developer console and see if there's any error in there (Cmd + Alt + J in most browsers)

@keiwanjamaly
Copy link
Author

keiwanjamaly commented Feb 23, 2018

@limzykenneth there seems to be an error message:

The first one is probably not the problem, it is fixed by adding

<meta charset="UTF-8">

in <head>
Die Zeichenkodierung des HTML-Dokuments wurde nicht deklariert. Das Dokument wird in manchen Browser-Konfigurationen mit verstümmeltem Text dargestellt, wenn das Dokument Zeichen außerhalb des US-ASCII-Bereichs enthält. Die Zeichenkodierung der Seite muss im Dokument oder Transferprotokoll deklariert werden. index.html

But the second looks more interesting, this happens when I try load the .txt from ../output_coord_cartesian.txt:

TypeError: NetworkError when attempting to fetch resource.
[Weitere Informationen]
p5.js:59833:5

When I try to load it from output_coord_cartesian.txt I get:
allocation size overflow
in the console. But there is still a Loading... message in the Browser.

@limzykenneth
Copy link
Member

How big is the file you are loading? I'll see if I can try to duplicate the issue on my side.

@keiwanjamaly
Copy link
Author

@limzykenneth
Here is the file. I hope you can read/download it. It's size is 706.8 MB
https://drive.google.com/file/d/1TUPcC5HRDnDEF3KM3BdM1hlJvafViRx_/view?usp=drivesdk

@limzykenneth
Copy link
Member

I finally got to test the file and it works as expected on Safari and Chrome but hit a memory allocation limit on Firefox. I'm not able to replicate your error but I would guess it has something to do with the max file size servable. Depending on your situation, you may need to explore other ways of using data from that file, either off load the lookup to a server or serving smaller chucks of files.

@keiwanjamaly
Copy link
Author

@limzykenneth Thank you, i'll tried to load the file in Firefox. I will try to load it with other Browsers and give you an update :)

@TanviKumar
Copy link
Member

#3127 solves this

@lmccart
Copy link
Member

lmccart commented Aug 13, 2018

fixed with #3127

@lmccart lmccart closed this as completed Aug 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants