-
-
Notifications
You must be signed in to change notification settings - Fork 962
avm1: implemented getBytesLoaded and getBytesTotal #22612
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
base: master
Are you sure you want to change the base?
Conversation
How did you find that? Have you tried playing a 5 GB sound? |
Yes, that's exactly how I did it. |
|
You can add a TODO for the u64 total bytes stuff. |
9676b3e to
721dc10
Compare
|
I was sleeping I think. My u64 should have been a u32 instead of the other way around. Has been changed in the last commit |
So it shouldn't be 64-bit? |
a889f08 to
ed45e67
Compare
9ea59af to
96bf0fd
Compare
No, should be 32 bit. I was sleeping or something I think |
| } | ||
|
|
||
| /// Estimate the length of a local file for a given request. | ||
| fn estimate_file_length(&self, request: &Request) -> Option<u32> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use SuccessResponse::expected_length()?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because that one is only available from a future and is not guaranteed to be ready.
Box::pin(async move {
let fetch = player.lock().unwrap().fetch(request, FetchReason::Other);
let mut response = fetch.await.map_err(|error| error.error)?;
...from core->src->loader.rs line 1273
response is inside the async block.
While flash always has the length ready on local files.
s.loadsound("local_filesystem_file.mp3", b_streaming);
trace(s.getBytesTotal());
always immediatly returns the amount of bytes in flash with local files. Ruffle is not guaranteed to do so in the async block with the response.
Or is it possible to get the SuccessResponse::expected_length() outside of the async block?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if the file is not local? Does it block until we get the content length header?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, It returns undefined on a non local file. In flash, and in Ruffle with this commit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have not added a file from a http request in the tests, because I am not sure if we can ensure that it will always be undefined, networking etc... Can we do that without problems?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we do that without problems?
I'm not sure how our tests work in this regard, there might be a race condition.
If it returns undefined for remote files, it's fine to return undefined for local files too in this iteration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it returns undefined for remote files, it's fine to return undefined for local files too in this iteration.
But that's not what the flash player does. The player always returns the size for local files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want to return file size synchronously, you'd need to refactor how fetching is done in order to allow supplying this information synchronously. Currently it's not possible because a future is returned that requires an await.
There's also the question of whether it's really done synchronously, or asynchronously but Flash manages to do it before reading the value in AS. We'd need to simulate a delay to reading a file and check whether something blocks in Flash or undefined is returned. I'm not fully convinced it's done synchronously, because Flash was mainly a web technology and it just doesn't make sense to implement it differently for local files compared to remote files.
I feel like the effort involved outweighs the benefits we get from it, that's why I think it's fine to return undefined for now.
No description provided.