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

Adds streams-lib polyfill and exports ReadableStream from shared/util. #8396

Merged
merged 1 commit into from
May 31, 2017

Conversation

mukulmishra18
Copy link
Contributor

@mukulmishra18 mukulmishra18 commented May 10, 2017

This is the first PR of project Streams API in PDF.js. This allow PDF.js to use Streams API in the process of networking and rendering. For that purpose, this PR:

  • Fork Streams API ref-implementation and convert it to commonjs module.

  • Import/Export ReadableStream from shared/util.js.

  • Adds test for ReadableStream to check it's working.

Increase in file size(in kb) after adding this code, in pdf.js and pdf.worker.js:

  • pdf.js: 468.8(after) - 343.7(before) = ~125

  • pdf.worker.js: 1400(after) - 1300(before) = 100

Copy link
Collaborator

@Snuffleupagus Snuffleupagus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First of all, please note that Travis has a lot of complaints about the code. In this case, since it concerns external code, I'd suggest simply adding external/streams/ to https://github.com/mozilla/pdf.js/blob/master/.eslintignore. Edit: Remember that running gulp lint helps catch these kind of issues locally.

Second of all, this will get bundled into all build targets by default. I imagine that we don't want to do that, at least not at the present time, since it would cause e.g. the FIREFOX/MOZCENTRAL builds to become quite a lot larger (for code that we currently don't use in production).

@mukulmishra18
Copy link
Contributor Author

I'd suggest simply adding external/streams/ to https://github.com/mozilla/pdf.js/blob/master/.eslintignore

Thanks for you suggestion. I will add the file.

this will get bundled into all build targets by default.

No idea what we have to do for this. Maybe we can compress the polyfill. Have to ask @yurydelendik .

@yurydelendik
Copy link
Contributor

the FIREFOX/MOZCENTRAL builds to become quite a lot larger

We need to follow https://bugzilla.mozilla.org/show_bug.cgi?id=1272697 for that. I'm expecting landing of streamable getTextContent as soon as we land this PR, so the code will be using streams api in production.

@timvandermeij
Copy link
Contributor

It looks like Travis does not see the library as a module. Is it a valid CommonJS module?

Moreover, the file looks built. I suspect one of the next steps will be to fetch the original from the repository and build it ourselves? In case the upstream library changes, it should be easy for us to rebuild our version from source.

@yurydelendik
Copy link
Contributor

yurydelendik commented May 10, 2017

TODO:

  • replace const assert = require('assert'); -- it adds some useless for us node.js stubs
  • on gulp lib and gulp dist copy "external/streams/" to the build/external/streams/ and build/dist/external/streams/ folder
  • use LICENSE.md from reference implementation in the external/streams/

gulpfile.js Outdated
gulp.src([
'src/{core,display}/*.js',
'src/shared/{compatibility,util}.js',
'src/{pdf,pdf.worker}.js',
], {base: 'src/'}),
], {base: 'src/'})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

too many irrelevant changes. let's make original marge as var buildLib = merge([...]); and then add

return merge([
   buildLib,
   gulp.src('external/streams/streams-lib.js', {base: '.'})
     .pipe(gulp.dest('build/'))
  ]);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, sure. Looks more clear. Thanks for suggestion.

gulpfile.js Outdated
gulp.task('dist', ['dist-repo-git']);
gulp.task('dist', ['dist-repo-git'], function () {
gulp.src('external/streams/streams-lib.js', {base: '.'})
.pipe(gulp.dest('build/dist/'));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this belong in the dist-repo-prepare task

@mukulmishra18 mukulmishra18 force-pushed the streams-lib branch 2 times, most recently from 453f613 to 21b1b01 Compare May 12, 2017 20:30
Added test for ReadableStream.

Adds ref-implementation license-header in streams-lib
and change gulp task to copy external/streams/ in build/
external/streams/ and build/dist/external/streams folder.

Adds README.md and LICENSE.md
@Snuffleupagus
Copy link
Collaborator

While I'd wish that the size impact of this patch was a bit smaller, I've got no formal objections here :-)
So, as far as I'm concerned, we can land this PR (with passing tests of course)!

/botio test

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

Command cmd_test from @Snuffleupagus received. Current queue size: 0

Live output at: http://54.215.176.217:8877/533ea717f83341b/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

Command cmd_test from @Snuffleupagus received. Current queue size: 0

Live output at: http://54.67.70.0:8877/6bd04c9c974ea96/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Failed

Full output at http://54.67.70.0:8877/6bd04c9c974ea96/output.txt

Total script time: 17.42 mins

  • Font tests: Passed
  • Unit tests: FAILED
  • Regression tests: FAILED

Image differences available at: http://54.67.70.0:8877/6bd04c9c974ea96/reftest-analyzer.html#web=eq.log

@pdfjsbot
Copy link

From: Bot.io (Windows)


Success

Full output at http://54.215.176.217:8877/533ea717f83341b/output.txt

Total script time: 25.92 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Regression tests: Passed

@Snuffleupagus
Copy link
Collaborator

/botio-linux test

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

Command cmd_test from @Snuffleupagus received. Current queue size: 0

Live output at: http://54.67.70.0:8877/b755221678801b6/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Failed

Full output at http://54.67.70.0:8877/b755221678801b6/output.txt

Total script time: 19.20 mins

  • Font tests: Passed
  • Unit tests: FAILED
  • Regression tests: FAILED

Image differences available at: http://54.67.70.0:8877/b755221678801b6/reftest-analyzer.html#web=eq.log

@Snuffleupagus
Copy link
Collaborator

Snuffleupagus commented May 20, 2017

It unfortunately seems that loading all of this new code has made the tests even more unreliable :-(
Even the unit-tests now timeout frequently, whereas they're fine when run against master.

@mukulmishra18
Copy link
Contributor Author

It unfortunately seems that loading all of this new code has made the tests even more unreliable :-(
Even the unit-tests now timeout frequently, whereas they're fine when run against master.

Not sure why this is happening(as all unit-tests are passing on my local machine) and what will be the potential solution of this :-(

But i think we can reduce the size of streams-lib file by removing all except ReadableStream(as we only need this for now) from streams.lib.entry.js file, as we are using this file to bundle streams-lib.

@Snuffleupagus
Copy link
Collaborator

Not sure why this is happening(as all unit-tests are passing on my local machine) and what will be the potential solution of this :-(

This is a pre-existing issue affecting only the Chrome browser on the Linux bot, and one that has thus far prevented landing for example PR #8284.
So while it's not the fault of this patch itself, it will probably still make landing this difficult at the moment (until a solution/workaround for the timeouts have been found).

Note that e.g. compared to PR #8284, the current PR seems to cause even worse timeouts on the Linux bot.

@yurydelendik
Copy link
Contributor

/botio test

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

Command cmd_test from @yurydelendik received. Current queue size: 0

Live output at: http://54.67.70.0:8877/8ca3c6c39e0ef85/output.txt

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

Command cmd_test from @yurydelendik received. Current queue size: 1

Live output at: http://54.215.176.217:8877/0e387beaad90426/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Success

Full output at http://54.67.70.0:8877/8ca3c6c39e0ef85/output.txt

Total script time: 17.73 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Regression tests: Passed

@pdfjsbot
Copy link

From: Bot.io (Windows)


Success

Full output at http://54.215.176.217:8877/0e387beaad90426/output.txt

Total script time: 30.14 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Regression tests: Passed

@yurydelendik yurydelendik merged commit bd288df into mozilla:master May 31, 2017
@yurydelendik
Copy link
Contributor

Thank you for the patch.

As a follow up let's check if we can bring code from https://github.com/mukulmishra18/streams-lib/ as is here.

movsb pushed a commit to movsb/pdf.js that referenced this pull request Jul 14, 2018
Adds streams-lib polyfill and exports ReadableStream from shared/util.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants