Sending an image in a Telegram chat doesn't work and causes high CPU usage
Categories
(Core :: Graphics: Canvas2D, defect)
Tracking
()
Tracking | Status | |
---|---|---|
firefox-esr78 | --- | unaffected |
firefox-esr91 | --- | unaffected |
firefox92 | --- | unaffected |
firefox93 | --- | fixed |
firefox94 | --- | fixed |
People
(Reporter: marco, Unassigned)
References
(Regression)
Details
(Keywords: regression)
STR:
- Capture a screenshot of an area of a page
- Paste it in a Telegram chat
The image is not pasted, and CPU usage increases and stays high until closing Firefox.
Reporter | ||
Comment 1•3 years ago
|
||
I can't reproduce in a clean profile.
Reporter | ||
Comment 2•3 years ago
|
||
Mozregression result: https://hg.mozilla.org/integration/autoland/pushloghtml?fromchange=5b283bdb31563a802b44a5c725965baafa190e6c&tochange=c153c24e55598c58307c6065a7e21e71d79bf676.
Reporter | ||
Comment 4•3 years ago
|
||
(In reply to Martin Stránský [:stransky] (ni? me) from comment #3)
Which OS is that?
Linux.
I can only reproduce when I copy a large enough image.
Mozregression points me to bug 1367251. Jeff, Angus, any idea?
Comment 5•3 years ago
|
||
Which telegram client? There appear to be several.
Comment 6•3 years ago
|
||
A quick scan through the source of the Telegram Z client shows it uses createImageBitmap and attempts to use the resize option properties. These options aren't implemented yet, and are ignored without raising an exception, why this leads to high CPU usage is unclear, since the code will just create an imageBitmap of the source image, without resizing. Are you pasting an very large image?
Reporter | ||
Comment 7•3 years ago
|
||
(In reply to Angus Sawyer from comment #6)
A quick scan through the source of the Telegram Z client shows it uses createImageBitmap and attempts to use the resize option properties. These options aren't implemented yet, and are ignored without raising an exception, why this leads to high CPU usage is unclear, since the code will just create an imageBitmap of the source image, without resizing. Are you pasting an very large image?
Yes, I'm using the https://web.telegram.org/z/ client (I think it is the default nowadays, I haven't really chosen it).
It works well if I paste a small image. It doesn't work if I paste a large image (but basically with a HiDPI screen any screenshot, even of small DOM nodes, is large).
Updated•3 years ago
|
Comment 8•3 years ago
|
||
I have worked out the cause of the high CPU etc you are seeing.
Because createImageBitmap() now accepts the options object, the Telegram client function scaleImage() assumes that the resize options are supported and returns the image created as a result, which in fact is just the same size as the image passed in.
The above resizing function is called from buildAttachment() to shrink images smaller than a predetermined size. buildAttachment() assumes the image has been resized and calls itself with the returned image at line 30 so we get an infinite loop here, constantly decoding the same image without any progress.
I have a patch for supporting the resize options, but it isn't in a state for submission, and might not be acceptable and is certainly too late for FF93, which leaves three options:
-
Revert these patches, further delaying options support.
-
Throw an exception for unsupported options properties, I don't know how this fits with standards, unknown option properties are ignored by FF and Chrome.
-
Add to checks to the telegram client to avoid the infinite loop and fall back to the alternative scaling mechanism in imageResize().
Reporter | ||
Comment 9•3 years ago
|
||
Angus, do you think this could be affecting other websites than Telegram and other use cases than pasting images?
I guess it is too late for 93 at this point, but what if we revert the patches only for 94 and keep them in 95 (assuming you can implement the resize option by 95)?
Comment 10•3 years ago
|
||
We should reach out to them to fix it. It's a bug in their code, not ours.
Comment 11•3 years ago
|
||
I have submitted a 3 line PR to the telegram client in question, that should fix this case.
There is a comment in the code that mentions that FF pre 93 doesn't support options, so someone has seen option support and assumed that resizing is supported without testing.
The telegram pattern of recusing is hopefully very rare, and any breakages would just result in an image not being resized rather than an infinite loop.
Reporter | ||
Comment 12•3 years ago
|
||
OK, thanks for the additional info. So do you think we should close this bug as WONTFIX?
Do you have a bug tracking support for the resize options?
Updated•3 years ago
|
Comment 13•3 years ago
|
||
There doesn't appear to be a specific bug for the resize options, I will probably create one.
I have brought the patch to add resizing up to date, it passes the web platform tests apart from the resize quality options which are ignored.
Reporter | ||
Comment 14•3 years ago
|
||
Let's fix the title and component to match reality.
Reporter | ||
Updated•3 years ago
|
Comment 15•3 years ago
|
||
See Bug 1733559
Comment 16•3 years ago
|
||
The severity field is not set for this bug.
:lsalzman, could you have a look please?
For more information, please visit auto_nag documentation.
Comment 17•3 years ago
|
||
The patch I sent for the Telegram 'Z' client has been accepted and Telegram now works with FF93.
Comment 18•3 years ago
|
||
Calling this fixed per comment 17.
Description
•