-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AsyncSeek
trait bound on Reader
may limit options to stream bytes
#12880
Comments
We need an async / streaming abstraction for assets, but |
AsyncSeek
trait bound on Reader
may limit options to stream bytes on webAsyncSeek
trait bound on Reader
may limit options to stream bytes
this is true for any asset reader that could work on a stream, it could make sense for large files on native too |
I'm just sharing my personal thoughts on it, maybe it will be interesting for others and exciting ideas will arise from it. I see both sides, on the one hand it can of course limit options to stream bytes for example with an http request that does not support seek, on the other side I think it is really handy in some cases to have the I don't think Of course, we would still have the problem that all custom readers still have to implement the Maybe it's the wrong approach to have the seek functionality in the reader, but in my personal opinion it feels pretty intuitive :) |
Hi, I just wanted to share my thoughts on this subject. The new Since I "pack" assets together and support compression, it's not easy to allow seeking on compressed assets. Currently, my workaround is to read the file into a temporary buffer to enable seeking. I chose this approach because I believe some "native" Bevy assets will likely take advantage of the seek feature, particularly meshlet meshes. However, this hack (mainly due to time constraints on this part, which isn't my main priority at the moment) completely negates the benefits of asynchronous reading, as I first need to move all the data to a buffer. This could be soblved with a custom trait like |
#12880 (#14194) # Objective The primary motivation behind this PR is to (partially?) address the limitations imposed by the recently added `AsyncSeek` trait bound discussed in issue #12880. While the `AsyncSeek` trait add some flexibility to the reader, it inadvertently restricts the ability to write asset readers that can truly stream bytes, particularly in scenarios like HTTP requests where backward seeking is not supported. It is also challenging in contexts where assets are stored in compressed formats or require other kinds of transformations. The logic behind this change is that currently, with `AsyncSeek`, an asset Reader based on streamed data will either 1) fail silently, 2) return an error, or 3) use a buffer to satisfy the trait constraint. I believe that being able to advance in the file without having to "read" it is a good thing. The only issue here is the ability to seek backward. It is highly likely that in this context, we only need to seek forward in the file because we would have already read an entry table upstream and just want to access one or more resources further in the file. I understand that in some cases, this may not be applicable, but I think it is more beneficial not to constrain `Reader`s that want to stream than to allow "Assets" to read files in a completely arbitrary order. ## Solution Replace the current `AsyncSeek` trait with `AsyncSeekForward` on asset `Reader` ## Changelog - Introduced a new custom trait, `AsyncSeekForward`, for the asset Reader. - Replaced the current `AsyncSeek` trait with `AsyncSeekForward` for all asset `Reader` implementations. ## Migration Guide Replace all instances of `AsyncSeek` with `AsyncSeekForward` in your asset reader implementations.
bevyengine#12880 (bevyengine#14194) # Objective The primary motivation behind this PR is to (partially?) address the limitations imposed by the recently added `AsyncSeek` trait bound discussed in issue bevyengine#12880. While the `AsyncSeek` trait add some flexibility to the reader, it inadvertently restricts the ability to write asset readers that can truly stream bytes, particularly in scenarios like HTTP requests where backward seeking is not supported. It is also challenging in contexts where assets are stored in compressed formats or require other kinds of transformations. The logic behind this change is that currently, with `AsyncSeek`, an asset Reader based on streamed data will either 1) fail silently, 2) return an error, or 3) use a buffer to satisfy the trait constraint. I believe that being able to advance in the file without having to "read" it is a good thing. The only issue here is the ability to seek backward. It is highly likely that in this context, we only need to seek forward in the file because we would have already read an entry table upstream and just want to access one or more resources further in the file. I understand that in some cases, this may not be applicable, but I think it is more beneficial not to constrain `Reader`s that want to stream than to allow "Assets" to read files in a completely arbitrary order. ## Solution Replace the current `AsyncSeek` trait with `AsyncSeekForward` on asset `Reader` ## Changelog - Introduced a new custom trait, `AsyncSeekForward`, for the asset Reader. - Replaced the current `AsyncSeek` trait with `AsyncSeekForward` for all asset `Reader` implementations. ## Migration Guide Replace all instances of `AsyncSeek` with `AsyncSeekForward` in your asset reader implementations.
Originally posted by @cart in #12547 (comment)
The text was updated successfully, but these errors were encountered: