Here's the SkStream::isAtEnd doc comment
(
https://skia.googlesource.com/skia/+/bc8ca57868d22e31481f05d7ad836ddf6a3a4cf7/include/core/SkStream.h#87)
/** Returns true when all the bytes in the stream have been read.
* This may return true early (when there are no more bytes to be read)
* or late (after the first unsuccessful read).
*/
virtual bool isAtEnd() const = 0;
If reading a traditional file or a SkData, whose size is known at
construction (ignoring the fact that files' sizes are mutable), then
the "all the bytes in the stream have been read" semantics are
straightforward.
But suppose that I'm reading from a pipe or a network socket. If I've
read 100 bytes and 100 bytes were available *so far*, but I don't know
whether more bytes are coming, should isAtEnd return true or false?
Does "all the bytes in the stream" mean "all the bytes, at this point
in time" or "all the bytes, now and in the future"?
In Skia's repository, src/codec/SkWuffsCodec.cpp says
(
https://skia.googlesource.com/skia/+/bc8ca57868d22e31481f05d7ad836ddf6a3a4cf7/src/codec/SkWuffsCodec.cpp#88)
b->meta.closed = s->isAtEnd();
And the semantics of the closed field on the LHS of the assignment is
that true means that we are *definitely* at EOF, "now and in the
future".
However, in Blink code in Chromium's repository, its
blink::SegmentStream class subclasses Skia's SkStream class. Its
isAtEnd() semantics are *possibly* at EOF, as far as we know "at this
point in time":
https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/platform/image-decoders/segment_stream.cc;l=82;drc=1feb33707da149b105a135acbea9193e01db0c20
Stepping back a little, blink::ImageDecoder::SetData does have a "bool
all_data_received" argument
(
https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/platform/image-decoders/image_decoder.h;l=269;drc=de5356c7681b31e9880823cd8ed46d80ac49131d)
which discriminates between "at this point in time" and "now and in
the future". But that bool isn't passed on to the WTF::SharedBuffer,
blink::SegmentReader, or blink::SegmentStream code.
---
So, either SkWuffsCodec.cpp's use of isAtEnd() or
blink::SegmentStream's implementation of isAtEnd() is incorrect, but I
can't tell which it is just from the SkStream::isAtEnd doc comment (or
studying the SkFILEStream or SkMemoryStream implementations, which
know the stream size at construction).
Is isAtEnd() "possibly EOF, at this point in time" or "definitely EOF,
now and in the future"?