[api-minor] Remove the postMessageTransfers
parameter, and thus the ability to manually disable transferring of data, from the API
#11123
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
By transferring, rather than copying,
ArrayBuffer
s between the main- and worker-threads, you can avoid unnecessary allocations by only having one copy of the same data.Hence manually setting
postMessageTransfers: false
, when callinggetDocument
, is a performance footgun[1] which will do nothing but waste memory.Given that every reasonably modern browser supports
postMessage
transfers[2], I really don't see why it should be possible to force-disable this functionality.Looking at the browser support, for
postMessage
transfers[2], it's highly unlikely that PDF.js is even usable in browsers without it. However, the feature testing ofpostMessage
transfers is kept for the time being just to err on the safe side.[1] This is somewhat similar to the, now removed,
disableWorker
parameter which also provided API users a much too simple way of reducing performance.[2] See e.g. https://developer.mozilla.org/en-US/docs/Web/API/MessagePort/postMessage#Browser_compatibility and https://developer.mozilla.org/en-US/docs/Web/API/Transferable#Browser_compatibility