@@ -309,6 +309,12 @@ func (ab *AsyncBuffer) Wait() (int, error) {
}
+// ReleaseThreshold releases the pause, allowing the buffer to immediately
+// read data beyond the pause threshold.
+func (ab *AsyncBuffer) ReleaseThreshold() {
+ ab.paused.Release()
+}
+
// Error returns the error that occurred during reading data in background.
func (ab *AsyncBuffer) Error() error {
err := ab.err.Load()
@@ -177,6 +177,10 @@ func (f *Factory) DownloadAsync(ctx context.Context, imageURL, desc string, opts
return nil, h, wrapDownloadError(err, desc)
+ // We successfully detected the image type, so we can release the pause
+ // and let the buffer read the rest of the data immediately.
+ b.ReleaseThreshold()
d := &imageDataAsyncBuffer{
b: b,
format: format,