Bug 138950 - JPEG looks as a black rectangle in Writer
Summary: JPEG looks as a black rectangle in Writer
Status: VERIFIED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
5.4 all versions
Hardware: All All
: medium normal
Assignee: Caolán McNamara
URL:
Whiteboard: target:7.2.0 target:7.1.0.0.beta2 tar...
Keywords: bibisected, bisected, regression
Depends on:
Blocks: Writer-Images
  Show dependency treegraph
 
Reported: 2020-12-15 17:08 UTC by Roman Kuznetsov
Modified: 2020-12-17 13:11 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
JPG that show you a problem (59.24 KB, image/jpeg)
2020-12-15 17:10 UTC, Roman Kuznetsov
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Roman Kuznetsov 2020-12-15 17:08:20 UTC
Description:
JPEG looks as a black rectangle in Writer

Steps to Reproduce:
1. Open Writer
2. Insert a image from attach into the Writer document
3. Look at a black rectangle instead an image

Actual Results:
JPEG image looks as a black rectangle in Writer document

Expected Results:
JPEG looks good 


Reproducible: Always


User Profile Reset: No



Additional Info:
Repro in 5.4 but not in 5.3 => a regression

I bisected it:

Домовой@▒▒▒▒▒▒▒-▒▒ MINGW64 /d/LO_bisect/bibisect-win32-5.4 ((oldest))
$ git bisect start master oldest
Bisecting: 3822 revisions left to test after this (roughly 12 steps)
Unlink of file 'instdir/share/fonts/truetype/NotoEmoji-Regular.ttf' failed. Should I try again? (y/n) n
warning: unable to unlink 'instdir/share/fonts/truetype/NotoEmoji-Regular.ttf': Invalid argument
[fb6ad3d5a416ac122c263bb29a8d1b90a0750432] source sha:055c8cc676921176e2b9df76bd0e09bacab1d80b

Домовой@▒▒▒▒▒▒▒-▒▒ MINGW64 /d/LO_bisect/bibisect-win32-5.4 ((fb6ad3d5a...)|BISECTING)
$ instdir/program/soffice --writer

Домовой@▒▒▒▒▒▒▒-▒▒ MINGW64 /d/LO_bisect/bibisect-win32-5.4 ((fb6ad3d5a...)|BISECTING)
$ git bisect good
Bisecting: 1911 revisions left to test after this (roughly 11 steps)
[e4ec339892e747e2dfd56126e74a90411fced190] source sha:a917902c48f21d04039da86048c5c36555137d7e

Домовой@▒▒▒▒▒▒▒-▒▒ MINGW64 /d/LO_bisect/bibisect-win32-5.4 ((e4ec33989...)|BISECTING)
$ instdir/program/soffice --writer

Домовой@▒▒▒▒▒▒▒-▒▒ MINGW64 /d/LO_bisect/bibisect-win32-5.4 ((e4ec33989...)|BISECTING)
$ git bisect bad
Bisecting: 955 revisions left to test after this (roughly 10 steps)
[374673a7108c11f5a2d352f522597414093decbc] source sha:dfdf256d828e29b430e41d1b82899680664259f5

Домовой@▒▒▒▒▒▒▒-▒▒ MINGW64 /d/LO_bisect/bibisect-win32-5.4 ((374673a71...)|BISECTING)
$ instdir/program/soffice --writer

Домовой@▒▒▒▒▒▒▒-▒▒ MINGW64 /d/LO_bisect/bibisect-win32-5.4 ((374673a71...)|BISECTING)
$ git bisect bad
Bisecting: 477 revisions left to test after this (roughly 9 steps)
[471e165665cd14f93d6df2fb5c0adb6efa95bca8] source sha:d4bdac90c3b12d1de74b99786f2e830ee2ae18dc

Домовой@▒▒▒▒▒▒▒-▒▒ MINGW64 /d/LO_bisect/bibisect-win32-5.4 ((471e16566...)|BISECTING)
$ instdir/program/soffice --writer

Домовой@▒▒▒▒▒▒▒-▒▒ MINGW64 /d/LO_bisect/bibisect-win32-5.4 ((471e16566...)|BISECTING)
$ git bisect bad
Bisecting: 238 revisions left to test after this (roughly 8 steps)
[24fb61ead7b93b430f8601762745fa057c2b3cd0] source sha:cb508b7faa8347dda4eea837af0dd36a246c572d

Домовой@▒▒▒▒▒▒▒-▒▒ MINGW64 /d/LO_bisect/bibisect-win32-5.4 ((24fb61ead...)|BISECTING)
$ instdir/program/soffice --writer

Домовой@▒▒▒▒▒▒▒-▒▒ MINGW64 /d/LO_bisect/bibisect-win32-5.4 ((24fb61ead...)|BISECTING)
$ git bisect bad
Bisecting: 118 revisions left to test after this (roughly 7 steps)
[6e23b73feba2c28faaf4b1d3122e8824fe08f38c] source sha:78ad9c3eb378c72e3cb1258f313b4b8c3023069c

Домовой@▒▒▒▒▒▒▒-▒▒ MINGW64 /d/LO_bisect/bibisect-win32-5.4 ((6e23b73fe...)|BISECTING)
$ instdir/program/soffice --writer

Домовой@▒▒▒▒▒▒▒-▒▒ MINGW64 /d/LO_bisect/bibisect-win32-5.4 ((6e23b73fe...)|BISECTING)
$ git bisect good
Bisecting: 59 revisions left to test after this (roughly 6 steps)
[a40409761d3025cd86f6c3bf2a62cc2f9a7a5fe5] source sha:646a1d20974ff13b908a85cdff37c2701d582d8f

Домовой@▒▒▒▒▒▒▒-▒▒ MINGW64 /d/LO_bisect/bibisect-win32-5.4 ((a40409761...)|BISECTING)
$ instdir/program/soffice --writer

Домовой@▒▒▒▒▒▒▒-▒▒ MINGW64 /d/LO_bisect/bibisect-win32-5.4 ((a40409761...)|BISECTING)
$ git bisect good
Bisecting: 29 revisions left to test after this (roughly 5 steps)
[ec47fbdfbaf3b6e93e96f09f2a933a1654356a5b] source sha:1a044b25c279236d9f67847ec6ad426d8c5aac13

Домовой@▒▒▒▒▒▒▒-▒▒ MINGW64 /d/LO_bisect/bibisect-win32-5.4 ((ec47fbdfb...)|BISECTING)
$ instdir/program/soffice --writer

Домовой@▒▒▒▒▒▒▒-▒▒ MINGW64 /d/LO_bisect/bibisect-win32-5.4 ((ec47fbdfb...)|BISECTING)
$ git bisect good
Bisecting: 14 revisions left to test after this (roughly 4 steps)
[db49ff70c6b91482254286e566bf325ee0664d53] source sha:7ae22f903e4d33867cd48088328cab627a3c43b8

Домовой@▒▒▒▒▒▒▒-▒▒ MINGW64 /d/LO_bisect/bibisect-win32-5.4 ((db49ff70c...)|BISECTING)
$ instdir/program/soffice --writer

Домовой@▒▒▒▒▒▒▒-▒▒ MINGW64 /d/LO_bisect/bibisect-win32-5.4 ((db49ff70c...)|BISECTING)
$ git bisect bad
Bisecting: 7 revisions left to test after this (roughly 3 steps)
[bbb615b02e1fe736b17aee1dbcc553c5d2f21713] source sha:3114d8a12eb14f27229ecaad6d810e2020b86441

Домовой@▒▒▒▒▒▒▒-▒▒ MINGW64 /d/LO_bisect/bibisect-win32-5.4 ((bbb615b02...)|BISECTING)
$ instdir/program/soffice --writer

Домовой@▒▒▒▒▒▒▒-▒▒ MINGW64 /d/LO_bisect/bibisect-win32-5.4 ((bbb615b02...)|BISECTING)
$ git bisect bad
Bisecting: 3 revisions left to test after this (roughly 2 steps)
[d998858c4ded3fcda88df41e8e5c6691af11bec9] source sha:f596e5d461b6436cdb6ee9efa59807d99bb54135

Домовой@▒▒▒▒▒▒▒-▒▒ MINGW64 /d/LO_bisect/bibisect-win32-5.4 ((d998858c4...)|BISECTING)
$ instdir/program/soffice --writer

Домовой@▒▒▒▒▒▒▒-▒▒ MINGW64 /d/LO_bisect/bibisect-win32-5.4 ((d998858c4...)|BISECTING)
$ git bisect bad
Bisecting: 0 revisions left to test after this (roughly 1 step)
[00f44f001903ea3155f8589742a4233488e58053] source sha:bed6a22318cf50f22c143708a24dc1638f677a5e

Домовой@▒▒▒▒▒▒▒-▒▒ MINGW64 /d/LO_bisect/bibisect-win32-5.4 ((00f44f001...)|BISECTING)
$ instdir/program/soffice --writer

Домовой@▒▒▒▒▒▒▒-▒▒ MINGW64 /d/LO_bisect/bibisect-win32-5.4 ((00f44f001...)|BISECTING)
$ git bisect good
d998858c4ded3fcda88df41e8e5c6691af11bec9 is the first bad commit
commit d998858c4ded3fcda88df41e8e5c6691af11bec9
Author: Norbert Thiebaud <nthiebaud@gmail.com>
Date:   Fri Mar 10 20:05:50 2017 -0800

    source sha:f596e5d461b6436cdb6ee9efa59807d99bb54135

https://git.libreoffice.org/core/+/f596e5d461b6436cdb6ee9efa59807d99bb54135

CC: to Caolan McNamara
Comment 1 Roman Kuznetsov 2020-12-15 17:10:15 UTC
Created attachment 168200 [details]
JPG that show you a problem
Comment 2 Caolán McNamara 2020-12-15 17:23:18 UTC
ImageMagick does report:

Premature end of JPEG file `PHOTO-2020-12-15-14-29-13.jpg' @ warning/jpeg.c/JPEGWarningHandler/389

so it does seem to be the case that the jpg is truncated. Though it is displayed in other image viewers
Comment 3 Caolán McNamara 2020-12-15 17:36:16 UTC
I can try allowing one truncated read to not abort the whole import
Comment 4 Roman Kuznetsov 2020-12-15 17:38:45 UTC
(In reply to Caolán McNamara from comment #2)
> ImageMagick does report:
> 
> Premature end of JPEG file `PHOTO-2020-12-15-14-29-13.jpg' @
> warning/jpeg.c/JPEGWarningHandler/389
> 
> so it does seem to be the case that the jpg is truncated. Though it is
> displayed in other image viewers

Just for info: it's a foto from Samsung smartphone, then it was sent to Whatsapp and then it was sent to my e-mail =)
Comment 5 Commit Notification 2020-12-16 08:41:59 UTC
Caolán McNamara committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/0eb8fd225e16b9bb810fc3574085a2c7914df2b6

tdf#138950 allow up to one short read to not trigger cancelling import

It will be available in 7.2.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 6 Commit Notification 2020-12-16 08:42:12 UTC
Caolán McNamara committed a patch related to this issue.
It has been pushed to "libreoffice-7-1":

https://git.libreoffice.org/core/commit/7fac9232088969823ebb2dbc1cde6bb9162b5475

tdf#138950 allow up to one short read to not trigger cancelling import

It will be available in 7.1.0.0.beta2.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 7 Caolán McNamara 2020-12-16 08:43:26 UTC
I'll allow one read failure to not cancel import of a jpg, which makes this example work without, hopefully, reintroducing the problem that a tiny broken jpg can take massive amounts of time to import
Comment 8 Caolán McNamara 2020-12-16 08:43:47 UTC
fixed in master and 7-1, backport to 7-0 in gerrit
Comment 9 Commit Notification 2020-12-16 11:43:50 UTC
Xisco Fauli committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/2ecdaa672b0362eb314afeea811c72cfa06bb20a

tdf#138950: vcl_jpeg_read_write: Add unittest

It will be available in 7.2.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 10 Xisco Faulí 2020-12-17 13:10:26 UTC
Verified in

Version: 7.2.0.0.alpha0+
Build ID: 4484accf4d331a95ebf8475d6cd91950f4c27bcc
CPU threads: 4; OS: Linux 5.7; UI render: default; VCL: x11
Locale: en-US (en_US.UTF-8); UI: en-US
Calc: threaded

Besides, there is a unittest for it.

@Caolán, thanks for fixing this issue!!
Comment 11 Commit Notification 2020-12-17 13:11:00 UTC
Caolán McNamara committed a patch related to this issue.
It has been pushed to "libreoffice-7-0":

https://git.libreoffice.org/core/commit/8b1efde9272adb2b7e4c438eba63193249216c9c

tdf#138950 allow up to one short read to not trigger cancelling import

It will be available in 7.0.5.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.