Skip to content
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

Ability to clear require() function's cache #243

Open
AceKiron opened this issue Jul 22, 2024 · 11 comments
Open

Ability to clear require() function's cache #243

AceKiron opened this issue Jul 22, 2024 · 11 comments
Labels
enhancement New feature or request

Comments

@AceKiron
Copy link

Request Description

Currently I have to manually reload my avatar (go into third person, hold R, then select Reload Avatar) in order to fix an issue caused by the fact the require() function is cached.

Could we get a feature that either clears the function's cache, disables its cache altogether, or a second require() function that doesn't cache?

@AceKiron AceKiron added the enhancement New feature or request label Jul 22, 2024
@KitCat962
Copy link
Contributor

Instead of bugging the devs to impliment a feature that bypasses your script issues, why not just fix your script so it works?

@KitCat962
Copy link
Contributor

What I mean is, require is behaving as require is expected to behave. There are currently no known issues with require that causes this issue. It is highly likely that instead of require being at fault, your script is at fault. Would you be willing to share your avatar so that we can figure out whether it is a require issue or a skill script issue?

@AceKiron
Copy link
Author

About a week ago I made a simplified version of my avatar public (https://github.com/AceKiron/A). It logs _Mx_Ace: Reloading avatar, NOT on server if I'm not playing on a specific server, and _Mx_Ace: Reloading avatar, on server if I am.
I'd expect a message to print out every time I join a server (that specific one, or any other one) or a singleplayer world. Instead it only prints out once.

@KitCat962
Copy link
Contributor

I downloaded your avatar and cannot reproduce your issue.
So long as the avatar is uploaded, it will always print something.

What exactly do you mean by require caching? I assumed that you meant that when require loads a script, it will retain the value and give the same value for each subsequent call of require in the same avatar instance. However, your script only has one instance of require. require's cache is always cleared when an avatar is reloaded, uploaded, whatever.

I have a feeling that you think that require caches the result between avatar reloads, which is incorrect. All avatars would break if that was the case.

If you still believe that figura is at fault for this, please provide video proof of just figura with no other mods and state the figura version and minecraft version. I need to see you uploading your test avatar in single player, exiting to menu, going back to the single player world. Then exit and join the server, waiting for your avatar to load. You will need to remove the mod check and use a different server for testing, as this test requires just figura.

Below is me doing just that, using my own ip as a test and removing the mod check. The only change made is line 1 of plugins/sample/index.lua, where I've changed the line to local playingOnTheServer = client:getServerData().ip == "IP", where IP is the ip address of my private server.

2024-07-22.15-46-17.mp4

@PoolloverNathan
Copy link
Contributor

Clearing the require cache wouldn't do anything anyway; all of the files it can load are already stored in a NBT blob that doesn't get modified after the avatar loads.

@AceKiron
Copy link
Author

I downloaded your avatar and cannot reproduce your issue. So long as the avatar is uploaded, it will always print something.

That's.. unexpected. That avatar didn't work on my PC at home.

What exactly do you mean by require caching? I assumed that you meant that when require loads a script, it will retain the value and give the same value for each subsequent call of require in the same avatar instance. However, your script only has one instance of require. require's cache is always cleared when an avatar is reloaded, uploaded, whatever.

I have a feeling that you think that require caches the result between avatar reloads, which is incorrect. All avatars would break if that was the case.

A lack of my avatar being reloaded is what's the problem here.

If you still believe that figura is at fault for this, please provide video proof of just figura with no other mods and state the figura version and minecraft version. I need to see you uploading your test avatar in single player, exiting to menu, going back to the single player world. Then exit and join the server, waiting for your avatar to load. You will need to remove the mod check and use a different server for testing, as this test requires just figura.

I'll do that once I come back home.

@AceKiron
Copy link
Author

If you still believe that figura is at fault for this, please provide video proof of just figura with no other mods and state the figura version and minecraft version. I need to see you uploading your test avatar in single player, exiting to menu, going back to the single player world. Then exit and join the server, waiting for your avatar to load. You will need to remove the mod check and use a different server for testing, as this test requires just figura.

I'm using Minecraft/FabricMC version fabric-loader-0.15.6-1.20.4, and Figura version figura-0.1.4+1.20.4-fabric-mc. Other than that I don't have any mods installed currently.

The plugins\sample\index.lua:1 line was changed to local playingOnTheServer = client:getServerData().ip == "localhost" for the purpose of this video.

The video was too big for me to upload on GitHub, so I uploaded it to YouTube instead: https://youtu.be/WS04fxiT5Ws.

@GrandpaScout
Copy link
Contributor

GrandpaScout commented Jul 26, 2024

It appears that init happens too early in 1.20.4.
It also throws when trying to convert the string "minecraft:barrier" to an item as if it didn't exist.

Testing shows that the script does in fact run over the print statement but just doesn't print anything because Minecraft (probably) has nowhere to print it to.

After more testing, I have no idea why the print isn't working. As far as I can tell, Figura should print the message as soon as it is available to. Yet it doesn't.

@KitCat962
Copy link
Contributor

Found the issue. 1.20.4 is not reloading the player at all between world loads. I think vanilla is doing some "optimizations" by keeping the Player entity in memory instead of creating a new instance. Figura only triggers the reload when a new instance is created.

Below video showcases this issue. Top left os 1.20.1, bottom right is 1.20.4. Expected behavior is when exiting to menu and rejoining the world, the player is reinitialized. This is showcased by the other minecraft instance uploading a different avatar. However, when 1.20.4 exits and rejoins the world, the avatar persists through the world transfer. Initialization scripts are not executed. Major bug plz fix

2024-07-26.17-51-53.mp4

@KitCat962
Copy link
Contributor

Can someone else figure out which versions of minecraft this occurs on? 1.20.1 has expected results, 1.20.4 does not. Still need to check 1.20.6 and 1.21

the following avatar was used to check:
printinit.zip

@Riftlight
Copy link
Contributor

Can someone else figure out which versions of minecraft this occurs on? 1.20.1 has expected results, 1.20.4 does not. Still need to check 1.20.6 and 1.21

Reproduced on 1.21 (same bug as you experienced in 1.20.4). i lack a 1.20.6 instance but its probably safe to assume its a bug on 1.20.4+

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants