Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

[release/3.1] Ensure Image.Save can handle non readable / seekable Streams #42994

Merged
merged 3 commits into from
Oct 13, 2020

Conversation

ericstj
Copy link
Member

@ericstj ericstj commented Sep 23, 2020

Port dotnet/runtime#36805 to release/3.1.

Original issue: dotnet/runtime#33522

Summary

When calling Image.Save and passing in a stream to write the image to we started throwing NotSupportedException if the stream could not be read. This happened accidentally as part of a performance fix in 3.x. That fix tried to ensure a seekable stream and would copy the backing stream contents when doing so. This was unnecessary work (and an unnecessary copy) since saving the image only requires writing and not reading nor seeking.

Customer Impact

Customer encounters NotSupportedException when trying to save an image when they did not before. This is blocking service update to 3.1 for the customer as well as preventing their upstack consumers of this service from updating.
Workaround would involve saving to a MemoryStream then copying to the final stream, which is undesirable. This significantly increases CPU and memory usage to a in a commonly used component low in the stack.

Regression?

Yes, from 2.1: dee4344

Testing

Unit tests added to cover this scenario. Partner has been using 5.0 fix.

Risk

Low. This is undoing a regression and fix has been in place in 5.0 for months.

@ericstj ericstj added bug Product bug (most likely) area-System.Drawing Servicing-consider Issue for next servicing release review labels Sep 23, 2020
Port of dotnet/runtime@00685a7

Fix Image.Save on Unix for write only non-seekable stream and remove
test which uses bogus handle value.
@leecow leecow added Servicing-approved Approved for servicing release and removed Servicing-consider Issue for next servicing release review labels Sep 24, 2020
@leecow leecow added this to the 3.1.10 milestone Sep 24, 2020
@Anipik Anipik merged commit a8bc235 into dotnet:release/3.1 Oct 13, 2020
@matthiaslischka
Copy link

Is there a prediction when v3.1.10 will be released? We face this issue in some 3rd party lib and have to decide if we can wait or have to work around.

@Anipik
Copy link

Anipik commented Oct 30, 2020

It will be released around 2nd week of november

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Drawing bug Product bug (most likely) Servicing-approved Approved for servicing release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants