-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Release object URL after image for resize has loaded #35499
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
Release object URL after image for resize has loaded #35499
Conversation
TanayParikh
left a comment
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.
Thanks @MichelJansson, this looks good to me. cc/ @MackinnonBuck as he was the original author in this area so would like to get his take.
|
@TanayParikh, Thanks for checking. I read somewhere that the main branch now was targeting .NET 7, is that correct? If so, should we change the target branch to one relevant for 6-rc2? |
From my understanding the |
|
@TanayParikh This looks good to me as well |
|
Did some quick additional manual validations, things are looking good, ready to merge! Thanks again @MichelJansson |
| const loadedImage = await new Promise(function(resolve: (loadedImage: HTMLImageElement) => void): void { | ||
| const originalFileImage = new Image(); | ||
| originalFileImage.onload = function(): void { | ||
| URL.revokeObjectURL(originalFileImage.src); |
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.
Should we also do this onerror? Is there an opportunity for that to happen?
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.
Sure, can't hurt. Note, we'll have to onerror = null first though: https://stackoverflow.com/questions/8124866/how-does-one-use-the-onerror-attribute-of-an-img-element
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.
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.
Good idea. I guess it would error out if the file sent wasn't an image?
@TanayParikh - Looks like the compiled dist/Release/blazor.*.js files didn't get this last update. From my understanding those also has to be committed?
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.
Good idea. I guess it would error out if the file sent wasn't an image?
More so if the image doesn't exist at all:
https://www.w3schools.com/jsref/event_onerror.asp
@TanayParikh - Looks like the compiled dist/Release/blazor.*.js files didn't get this last update. From my understanding those also has to be committed?
Usually yes, however given the final change wouldn't have any effect on tests, updating the file isn't strictly necessary here (I also didn't have push permissions via git due to this branch being on a separate fork, only could make changes via GitHub UI). Regardless, the update will be picked up automatically via the next change-set. Good eye though! 😄
|
/backport to release/6.0 |
|
Started backporting to release/6.0: https://github.com/dotnet/aspnetcore/actions/runs/1167375618 |
|
@TanayParikh backporting to release/6.0 failed, the patch most likely resulted in conflicts: $ git am --3way --ignore-whitespace --keep-non-patch changes.patch
Applying: Release object URL after image for resize has loaded
warning: Cannot merge binary files: src/Components/Web.JS/dist/Release/blazor.server.js (HEAD vs. Release object URL after image for resize has loaded)
Using index info to reconstruct a base tree...
M src/Components/Web.JS/dist/Release/blazor.server.js
Falling back to patching base and 3-way merge...
Auto-merging src/Components/Web.JS/dist/Release/blazor.server.js
CONFLICT (content): Merge conflict in src/Components/Web.JS/dist/Release/blazor.server.js
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 Release object URL after image for resize has loaded
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
Error: The process '/usr/bin/git' failed with exit code 128Please backport manually! |
Co-authored-by: Tanay Parikh <[email protected]>
…` to 6.0 (#35712) * Release object URL after image for resize has loaded (#35499) Co-authored-by: Tanay Parikh <[email protected]> * Updated release.js files Co-authored-by: Michel Jansson <[email protected]>
|
Hi All, This error still appears to be happening in a .Net 7 Blazor WASM PWA app :( After calling e.File.RequestImageFileAsync I can see the blob is created in the chrome sources tab. Will the fix mentioned above made it's way into the .Net 7 release? I am running as a client side Blazor WASM/PWA and therefore internally navigating between pages rather than just a traditional redirect in the browser, could that mean that the revokeObjectURL is never called? Thanks and Regards |
@MikeReedGH The fix was implemented into .NET6 so should also have been released with .NET7. I can still see the fix in the main branch. If i remember correctly, the blobs will still be visible under the sources tab even though they have been released. Try and open the URL's from the sources tab to see if they actually still exist (.3 of the manual testing suggested in the PR description) |
|
@MichelJansson. Thanks for replying. Ah ok, so the blobs still showing may just be a red herring!? I'll check. I do still have the problem....as soon a user selects a photo/or takes a camera photo that the WASM app just immediately crashes and restarts. It's not a silly bug in my handling of the IBrowserFile. I have quadrupled checked. Thanks |
Releases/revokes objectURL of original image (sent to
toImageFile) after it has been loaded, as it is no longer needed after that point.No automated tests added, as there is no simple way (without overriding APIs anyway) to find/get existing objectURL's.
Manual testing however shows that the URL's are released by;
Fixes #35156