Always prefer the PDF.js JPEG decoder for very large images, in order to reduce peak memory usage (issue 11694)
Always prefer the PDF.js JPEG decoder for very large images, in order to reduce peak memory usage (issue 11694)

When JPEG images are decoded by the browser, on the main-thread, there's a handful of short-lived copies of the image data; see https://github.com/mozilla/pdf.js/blob/c3f4690bde8137d80c74203b1ad91476fc2ca160/src/display/api.js#L2364-L2408
That code thus becomes quite problematic for very big JPEG images, since it increases peak memory usage a lot during decoding. In the referenced issue there's a couple of JPEG images whose dimensions are `10006 x 7088` (i.e. ~68 mega-pixels), which causes the *peak* memory usage to increase by close to `1 GB` (i.e. one giga-byte) in my testing.

By letting the PDF.js JPEG decoder, rather than the browser, handle very large images the *peak* memory usage is considerably reduced and the allocated memory also seem to be reclaimed faster.

*Please note:* This will lead to movement in some existing `eq` tests.

showpad/mozilla-pdf.js,showpad/mozilla-pdf.js,mozilla/pdf.js,Snuffleupagus/pdf.js,nawawi/pdf.js,macroplant/pdf.js,mozilla/pdf.js,xavier114fch/pdf.js,Shoobx/pdf.js,caremerge/pdf.js,nawawi/pdf.js,timvandermeij/pdf.js,Shoobx/pdf.js,showpad/mozilla-pdf.js,macroplant/pdf.js,Shoobx/pdf.js,xavier114fch/pdf.js,Snuffleupagus/pdf.js,timvandermeij/pdf.js,nawawi/pdf.js,macroplant/pdf.js,timvandermeij/pdf.js,mozilla/pdf.js,Snuffleupagus/pdf.js,caremerge/pdf.js