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

Report progress in loader .parse() #10731

Closed
fraguada opened this issue Feb 5, 2017 · 11 comments
Closed

Report progress in loader .parse() #10731

fraguada opened this issue Feb 5, 2017 · 11 comments

Comments

@fraguada
Copy link
Contributor

fraguada commented Feb 5, 2017

Description of the problem

TL;DR:
Does it make sense to have onProgress reporting during a Loader's .parse() method?

Keep reading...
Recently I switched from using ObjectLoader.load() to ObjectLoader.parse(). The reasons for switching are that I really had no need for actually loading a file, I can just parse the information just the same. I gain one less dependency on XHR, on the other hand however, I loose onProgress information while things are being parsed.

Loaders work well to report onProgress information in the load() method. I'd be interested to hear if anyone would find it useful to also include a similar onProgress on the .parse() method. I understand the mechanism to report the progress is different, .load() uses XHR total vs loaded bytes, whereas in .parse(), there is no mechanism in place to understand the bytes parsed vs total. There could be, however, an understanding of total things to parse. I'm mainly thinking of the ObjectLoader where there is parseGeometries, parseTextures, etc.

Loading Manager works to a certain extent to describe if 'files' are being loaded, and in my case, I do have base64 encoded images in the JSON data which it does report loading during the progress. But if I have a rather large set of geometries with say, only one texture, I don't get any meaningful information regarding where we are in the geometry loading. My files tend to have a lot of geometry pieces.

I do not want to add unnecessary overhead, and it would be great if there was an abstract way to handle all loading situations, as well as allow people to opt in or out of such progress reporting.

@RemusMar
Copy link
Contributor

RemusMar commented Feb 5, 2017

I'd be interested to hear if anyone would find it useful to also include a similar onProgress on the .parse() method.

Why do you need something like that?
Huge parse time = bad design

@fraguada
Copy link
Contributor Author

fraguada commented Feb 5, 2017

How do you avoid huge parse time with 10-100mb models?

@Mugen87
Copy link
Collaborator

Mugen87 commented Feb 5, 2017

Parsing is usually done in the main thread and a sequential process. While parsing, everything else in your application is blocked. Even UI updates are not possible. One approach to avoid this problem is to encapsulate your parsing logic into a separate thread (Web Worker) and report the results via messaging into your main thread.

See: https://www.html5rocks.com/en/tutorials/workers/basics/

@fraguada
Copy link
Contributor Author

fraguada commented Feb 5, 2017

@Mugen87 I guess I should read though #9756

@Mugen87
Copy link
Collaborator

Mugen87 commented Feb 5, 2017

Looks good 😉

@RemusMar
Copy link
Contributor

RemusMar commented Feb 6, 2017

How do you avoid huge parse time with 10-100mb models?

Stay away from JSON, OBJ, DAE and other text formats.
For best results use binary (and compressed) formats.
Example: http://necromanthus.com/Test/html5/SMC.html

@makc
Copy link
Contributor

makc commented Feb 7, 2017

what would you need progress event for if you cant actually display the progress? unless you use the worker, as suggested above, your UI is locked until parse method is done

@fraguada
Copy link
Contributor Author

fraguada commented Feb 7, 2017

@makc the point is to be able to track the progress. Thanks to @Mugen87, it is clear this will probably need to happen with a Worker.

@mrdoob
Copy link
Owner

mrdoob commented Feb 8, 2017

ObjectLoader basically relies on JSON.parse() which doesn't provide a progress event.

@mrdoob mrdoob closed this as completed Feb 8, 2017
@makc
Copy link
Contributor

makc commented Feb 8, 2017

@mrdoob you could use replacer argument, I guess

@mrdoob
Copy link
Owner

mrdoob commented Feb 8, 2017

Every time we try to put hacks in the hack bites us in the butt...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants