Autofish

Autofish

657k Downloads

Accessing LegacyRandomSource from multiple threads

bajspunk opened this issue ยท 20 comments

commented

crash-2022-06-27_01.30.50-server.txt

https://i.imgur.com/knuIDVg.png (settings)

I was just trying your sick mod but after like 10 second it just crashed :(

commented

Can't seem to reproduce (yet!), which probably means that there might be something with your setup (that I haven't gotten ahold of).

If you're using something like PolyMC/MultiMC, it would be greatly appreciated if you exported your instance and uploaded it somewhere so I can take a closer look at what the hell is going on.

commented

Can't seem to reproduce (yet!), which probably means that there might be something with your setup (that I haven't gotten ahold of).

I have the same issue, the thing is that when you move minecraft to the background. https://pastebin.com/d8wjhWUW

commented

Can't seem to reproduce (yet!), which probably means that there might be something with your setup (that I haven't gotten ahold of).

I have the same issue, the thing is that when you move minecraft to the background. https://pastebin.com/d8wjhWUW

Background as in... minimise?

commented

I have the same issue, while its in the background too. Not necessarily minimized, but just windowed and not focused. I'm also using the Dynamic FPS mod, which slows down rendering while MC is not focused. That's the only other mod I can think of that does things while MC is in background.

commented

Here are my mods, probably there's someone that's causing it to crash. https://ibb.co/n8DsvMw

commented

Of Jayjoe4's mods, I also have dynamic fps, lambdynamiclights, lazydfu, lithium, sodium, mod menu, and iris. Also the crash happened today with it being full screen as well.

Heres the info given by the crash helper mod: https://pastebin.com/ws9UhS5N

commented

Have not crashed yet after enabling "Force Multiplayer Detection". I got into the same issue when the game was minimized or not focused before. And I also have dynamic fps.

commented

Force Multiplayer Detection helps a lot but I still get the crash eventually. I think it is triggered by load (f.e. when compiling something on the laptop while Minecraft is still running on the background). I, too, am using Dynamic FPS.

I uninstalled dynamic fps and updated all my mods to the latest version and no crash at all, also not using the force multiplayer detection, make sure to update drivers as well

commented

Force Multiplayer Detection helps a lot but I still get the crash eventually. I think it is triggered by load (f.e. when compiling something on the laptop while Minecraft is still running on the background). I, too, am using Dynamic FPS.

commented

Yeah, unfortunately Dynamic FPS is pretty much mandatory for some of the folks on our servers. So far we've just been dealing with the client crashes but I thought I'd mention here they still occur. It's a lot more annoying now than it would have been a year ago because Microsoft auth has to be refreshed way too frequently.

commented

Yeah, unfortunately Dynamic FPS is pretty much mandatory for some of the folks on our servers. So far we've just been dealing with the client crashes but I thought I'd mention here they still occur. It's a lot more annoying now than it would have been a year ago because Microsoft auth has to be refreshed way too frequently.

I'm sure the answer is talking directly to the developer of dynamic fps, send him this repository and the information that's needed. ๐Ÿคธ

commented

Hmm, you think it's not simply that AutoFish is using the legacy Random somewhere and it's normally fine merely because vanilla Minecraft has almost no multithreading? That's what I would have guessed but I've not gone and looked at the source of either mod yet.

commented

Looking at it some more, I've been trying to understand why there is server code like MinecraftServer.runServer() in the client stack trace when not using the integrated server. I am not sure I completely understand how the mod functions. I did notice AutoFish was getting installed on the server (oops) so I've removed it and if that helps I'll eventually mention it here.

commented

Uploaded fixed version to CurseForge. Closing issue

commented

Looks like the error is occurring when calling the useItem() method on the FishingRodItem class. It plays a sound and generates a random value for the pitch of the sound (this is vanilla behavior, not caused by Autofish). The world.getRandom().nextFloat() is where the exception occurs:

world.playSound((PlayerEntity)null, user.getX(), user.getY(), user.getZ(), SoundEvents.ENTITY_FISHING_BOBBER_RETRIEVE, SoundCategory.NEUTRAL, 1.0F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F));

I'm not really sure of the exact reason it happens with DynamicFPS installed. For the 1.19.3 release I've added a try catch around the code block where Autofish calls useItem(). It's not really an ideal solution but it should prevent the game from crashing and shouldn't prevent fish from being caught.

commented

I think I have the same crash as this, using the latest version Autofish 0.9.7-SNAPSHOT

crash-2023-02-05_13.54.51-server.txt

I also have dynamic FPS installed, and the client crashed while MC was out of focus, so yeh, seems like probably the same thing. I'll try again without dynamic fps.

commented

world.getRandom() is not thread safe?

After AFK fishing without dynamic FPS for an hour i didn't hit the problem again, so it seems like that could be the work around... either that or turn off game sounds should also avoid the problem.

The Friendly Creatures toggle controls the bobber splash sound, for some reason:
https://bugs.mojang.com/browse/MC-139041?attachmentSortBy=dateTime

commented

Clearly my "workaround" has done nothing to help. I can do some more testing but may not be able to come up with an easy fix. Obviously the Dynamic FPS mod is not expecting player input while the game is not in focus.

commented

My new theory is that crash is due to tickFishingLogic() mixin hook executing in the Server thread, which is probably bad practice anyway. I've instead wrapped the logic in client.execute() to make this happen in the Render thread.

Since I have yet to replicate the issue, I've uploaded a compiled test version below for anyone to try out. You will have to rename the file from .zip to .jar. If this resolves the issue I will replace the current version on CurseForge.

Autofish-0.9.8-TEST-fabric-mc1.19.3.zip

commented

Proposed fix seems good to me.

With Autofish-0.9.7-fabric-mc1.19.3.jar I crash 5 times in 45 minutes.

With Autofish-0.9.8-TEST-fabric-mc1.19.3.jar same world same settings, after 1 hour afk fish no crash.