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

vttjs takes a long time (1s) to parse really long files, isn't optimized by engines #340

Open
gkatsev opened this issue Jun 2, 2015 · 4 comments

Comments

@gkatsev
Copy link
Contributor

gkatsev commented Jun 2, 2015

If you use a really large webvtt file (like here http://jsbin.com/hewamuwali/1/edit?html,output, with 1553 cues), vttjs takes around 1 second to parse the file.
One of the reasons is that the parse function uses a lot of try/catches and some engines (for example, v8) do not optimize these functions, so, they never run as fast as possible.
Also, this function runs synchronously rather than asynchronously. This means that if it takes a long time to parse the file, everything else in the application will hang.
The parse function should be broken up to chunk processing of the file asynchronously to hand back execution time to the page. Also, try/catches should either be wrapped or removed altogether.

@heff
Copy link
Contributor

heff commented Jun 3, 2015

FYI, the video won't work in the linked jsbin because flash isn't supported there, you need to go to the preview version o the bin. http://output.jsbin.com/kopuqizomo/1

@gkatsev the captions don't show at all in those examples. Is that expected?

I definitely see the drag though, in Chrome and Safari. What do you mean by chunk processing, specifically? Just dropping a setTimeout(fn, 0) around some of the bulky operations?

@gkatsev
Copy link
Contributor Author

gkatsev commented Jun 3, 2015

They start at around 27 seconds.

Basically, process a bit of the file at a time. Around 100-200ms at a time or maybe like 30 cues. And wrap each chunk in a setTimeout.

@gkatsev
Copy link
Contributor Author

gkatsev commented Sep 23, 2015

@RickEyre any thoughts on this? Thanks!

@altaywtf
Copy link

hi guys, any updates/workarounds about this?

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

3 participants