MV/MZ location.reload() issues

Hello coders again ^^

this issue bothers me a bit.

In RPG MV when use "location.reload()", the game reboot to the title screen, can start new game
or use continue to load a game without any issues, everything works here.

In RPG MZ when using "location.reload()", the game behave as normal, can start new game
or load a save file.

the issue rather in MZ is that the sprites aren't loaded at all, but the events are there.

weirdly enough, moving sprites does shows up, and interaction with events show the sprite as well.

how can I use "location.reload()" to also load the MZ assets as sprites mostly, as this should work
for MV as well, if not, I can guard it with my MV/MZ check as I want to release a new plugin "htmlError"
which can create fake errors as well for real ones that can show up, but I need to fix location.reload() function.

but I can't find relevant function as "sceneManager.goto(Scene_Boot)" or title, it just freezes up.
so I got stuck here on how to do this correctly.

so if there is any help or a way to use the location.reload(), it would be nice.

window.location.href = window.location.href didn't work either, so if you go any idea's for me to try,
I would be grateful.
I guess you're trying to hard reset the game? You have to do more than go to the title. Basically need to simulate exit and reload without actually doing so.

You can try to clear PIXI before the reload.
JavaScript:
if (PIXI.utils && PIXI.utils.clearTextureCache) {
    PIXI.utils.clearTextureCache();
}

ImageManager.clear();

And maybe try this for cache busting, instead of what you have.

JavaScript:
window.location.href = window.location.pathname + "?reload=" + Date.now();
I guess you're trying to hard reset the game? You have to do more than go to the title. Basically need to simulate exit and reload without actually doing so.

You can try to clear PIXI before the reload.
JavaScript:
if (PIXI.utils && PIXI.utils.clearTextureCache) {
    PIXI.utils.clearTextureCache();
}

ImageManager.clear();

And maybe try this for cache busting, instead of what you have.

JavaScript:
window.location.href = window.location.pathname + "?reload=" + Date.now();
I didn't heard of that, but certainly gonna try.

for what I know, "location.reload()" is similair to F5, but MZ prevent some caching problems
where MV seems to be softer, so it works really nice there.

I will come back after testing.

Edit:
on testing, sprites stays invisible. so it isn't reloaded, but the timeing seems
promising, so I gonna try to work on it, see what I can come up with or a different
approach...

I'm still open for any other approaches that may work out.

Edit 2:
I found a cleaner way I think, if not the best, it works for MZ, but I guard it
so it will be skipped when used in MV.
JavaScript:
    if (Utils.RPGMAKER_NAME === "MZ") {
        SDJB_htmlBase["Error"]._ImageManager_loadBitmap = ImageManager.loadBitmap;
            ImageManager.loadBitmap = function(folder, filename) {
                const bitmap = SDJB_htmlBase["Error"]._ImageManager_loadBitmap.call(this, folder, filename);
                    bitmap.addLoadListener(() => {
                        if (bitmap._baseTexture) {
                            bitmap._baseTexture.update();
                        }
                });
                return bitmap;
            };
    };

I don't know if its the best way for MZ re-render sprites on reload, but its the best
I have currently, but open for better approaches if exist.

So I keep this thread open for a while longer, as any other approaches are learning curve.
for me and others that like to learn new methods =).

I may put the above code into my htmlBase, just in case, so its more global in order
all my html can work out in case it happens on a different plugin.
Do you absolutely need to use location.reload() ?
When I need to hard reset the game, I personally use "chrome.runtime.reload();", (which is, I believe, the way how MZ reload the window on F5), works on both MV and MZ.
Hopefully that help !
Do you absolutely need to use location.reload() ?
When I need to hard reset the game, I personally use "chrome.runtime.reload();", (which is, I believe, the way how MZ reload the window on F5), works on both MV and MZ.
Hopefully that help !
it may work, but if they doesn't use chrome, but another, it may fail.
location.reload() is a simply browser reload, mozerella I believe can do location.reload(true).
but doesn't always work either.

if chrome is global, it can work out, but while it works in MV nicely, MZ sprites stops working.
but the reason is that I use that call in my other base as well for MV, so something that
work for MV/MZ is nice, but should work across any browser.

I use Vivaldi browser which is chrome based, so I can expect to work there.
other browser outside chrome is unknown as I don't use other, so harder to test.

I definitely going to check that as if it does work, it is at least a one liner which is nice.
specially for cross engine, but didn't found that while searching, so I wonder why.

thanks for that insight, gonna test it and let you know if it worked or not.
I just work on something else for now so I do once I got time, probably in a few hours.

Edit:
@Drag I tested out the chrome.runtime.reload(), but it gave the same results, not full
reset in MZ, so what I have to re-render the sprite on reload from imageManager seems
still the best solution I have.

I think it has something to do by manipulating the DOM though.

Original thread: https://forums.rpgmakerweb.com/threads/location-reload-issues.183224/