Mumfrey / WorldEditWrapper

WorldEditWrapper allows WorldEdit to be used in single player
9 stars 0 forks source link

WEW Freezing on the "Loading World" Screen #3

Closed LaughingLeader closed 10 years ago

LaughingLeader commented 10 years ago

First of all, thanks for developing this mod. WorldEdit is such a huge time-saver for me, so it's amazing to be able to use it once more.

Summary:

WEW runs fine on the first run, then freezes up on each subsequent load of my world. Deleting Waila's config file allows me to load the world once more. Disabling WEW/WECUI allows me to load the world without deleting Waila's config file.

Mod List:

http://pastebin.com/va8UJ5Hf

In-Depth:

I'm having a strange issue with WorldEditWrapper. When I first load my world with WEW and my other mods, everything seems okay. When I exit the world, restart Minecraft, and load that world back up, Minecraft gets stuck at "Loading World" and seemingly freezes there. It doesn't crash. I left Minecraft running for a few hours just to make sure it doesn't crash, and sure enough, it was still stuck there when I came back and checked on it.

In the console log, MC gets stuck right here:

Attemping to load JABBA data.

[11:15:08] [Server thread/INFO]: Preparing start region for level 0

[11:15:08] [Server thread/INFO] [Project Red]: Created Retrogen database for dimension 0

[11:15:09] [Server thread/INFO]: Preparing spawn area: 96%

[11:15:09] [AromaBackup/INFO]: [§1AromaBackup§r] Starting Backup. Server may lag for a bit!

[11:15:09] [Server thread/INFO]: Changing view distance to 4, from 10
//Stuck here forever

Deactivating WEW and WECUI allows me to get within my world once more. Further investigation revealed that deleting my config files and loading the world back up worked as well.

I took this even further and (for whatever reason), deleting my Waila config file "fixed" the issue (until I exited my world - then I had to delete the Waila config file once more).

This leads me to believe that there's some kind of issue between WEW and Waila, yet I'm not entirely sure which mod is at fault.

Additional Notes:

I tried disabling other mods before I stumbled on the config file "solution". Sometimes my world would load, and I thought I had fixed the issue. Yet, upon reloading my world, I was suddenly was stuck on the loading screen one more.

Deleting the Waila config file or deactivating WEW was really the only thing that worked 100% of the time.

Mumfrey commented 10 years ago

Can you post the entire developer console log. It's more than likely that something is erroring out at startup but not having an effect until you go in-game. Particularly we're looking for any suspicious (even if they look unrelated) exceptions being thrown at startup. It's very possible that the reason it "hangs" is that the server thread is dying completely and the client thread doesn't realise, so it's kind of a big issue to troubleshoot without more info.

The weird thing is, WEW doesn't really do very much that interacts with the game, it hooks in at various places but mostly it sits and does nothing except wait for a command/block click, so why it should cause a hang at startup is actually a little bizarre, but could be related to plugin channel traffic or other handshaking which occurs on world join.

Please post the whole log and we will troubleshoot further.

LaughingLeader commented 10 years ago

Sure thing.

Here it is: https://gist.github.com/LaughingLeader/c6568601b24537be45dd#file-wew-waila-loading-freeze-log

Mumfrey commented 10 years ago

Holy crap that's a lot of errors at startup. I'd start by removing the most obviously broken mods:

LaughingLeader commented 10 years ago

Ah, thanks. Honestly have no idea why Blockbreaker was still in there, or how it didn't crash Minecraft.

Took both Blockbreaker and Deconstruction out - still getting the same issue.

Chisel has a few errors in there, yet is suppose to be fine for 1.7.10, I believe (the forum thread has 1.7.10 included as a tag, but I'm a little skeptical now).

LaughingLeader commented 10 years ago

I believe I've pinpointed the real problem.

I decided to play some more this morning, and much to my surprise, the "Waila config deletion" solution was no longer working. Seems like it was a false positive, as I'm sure I confirmed it to work multiple times.

This bothered me, so I created a new Minecraft folder instance and put in WEW and Waila (and what Waila needs, i.e. NEI and so forth) for my mods. No problem loading a world.

From there, I put in my other mods in smaller clumps and tested each to see if I'd start getting the freezing bug again. It took me a little while, but now it seems that adding BetterFoliage is when the freezing occurs. Removing it alleviates the issue.

I double checked that this is the real problem by removing BetterFoliage from my original instance - sure enough, I can load my world once more.

I did one final test by creating another new instance and putting in just WEW and BetterFoliage. Same issue with freezing on loading a world. Looks like this is the actual incompatibility. Not Waila.

Just to reiterate, it looks like BetterFoliage and WEW are incompatible somehow, as just putting the two together creates the issue.

Sorry about that. Should have done all this testing beforehand.

Mumfrey commented 10 years ago

That makes sense, I figured it wouldn't be WAILA. I can't imagine what BF is doing which is causing the problem, looking at their source it doesn't appear like they would overlap at all but I haven't really looked at it in depth.

LaughingLeader commented 10 years ago

Figuring out this bug has been a pretty bizarre experience.

Initially I didn't have Waila, as I was waiting for the 1.7.10 release. Once that came out, I put it in with the other mods and everything seemed fine. Then my world froze on load the next time I played.

I'm pretty certain BetterFoliage was in the mix when that happened (it's in my pastebin mod list), and when I messed with deleting config files to see if anything would work.

So this has really left me confused on how this bug came to be, and why deleting config files worked before.

I feel a little saner now, knowing that the bug is reproducible with just the two mods. :relieved:

octarine-noise commented 10 years ago

The only thingthat happens on world load is BlockMatcher.handleWorldLoad(), whick iterates over the block registry. Dunno how that can be a problem.

Mumfrey commented 10 years ago

The only thingthat happens on world load is BlockMatcher.handleWorldLoad(), whick iterates over the block registry. Dunno how that can be a problem.

WorldEditWrapper doesn't touch the block registry at all, so I doubt that's the cause. The only thing I can think might be triggering it is when WER "boxes" the World instance is inadvertantly triggering some issue, but I have no idea what since all it does is store a reference to the World in a WeakReference object.

The only even vaguely unhealthy thing I see in your code mentioned above is that you're calling Class.forName a whole bunch of times ((blacklist.length + whitelist.length) * blockRegistry.size) in the matchesClass method rather than building blacklist/whitelist classes list at postInit time which might be safer. Of course if blacklist/whitelist are empty then that won't have any impact.

octylFractal commented 10 years ago

Okay, I did a lot of tracing and digging, and I got the problem.

The LaunchClassLoader is required to transform classes as they are loaded, which means that no matter which thread it is, it transforms them. This means that transformers must ensure that they put (if possible) zero locks on anything. This isn't the case with the Better Foliage transformer. It uses annotations to accomplish its goals. Some of the internal annotation stuff is synchronized, so when WE (not WER) tries to init on the world load given to it by WER, it tries to grab an annotation and deadlocks.

Solution: None I have thought of yet. It's a hard to resolve deadlock.

Stacks for the deadlock: http://pastebin.com/HBZ6Kb58

octylFractal commented 10 years ago

It seems that the related JVM bug (http://bugs.java.com/bugdatabase/view_bug.do?bug_id=7122142) was resolved in Java 8, but until then EZTransformer might need to stop using annotations.

octarine-noise commented 10 years ago

@Mumfrey yeah, you're right about the class list. It would be cleaner.

@kenzierocks thanks, you've saved me a lot of headache. I didn't know about this locking issue with annotations. I'll figure something out.

I think this can be closed, it'll be fixed in the next BF.

Mumfrey commented 10 years ago

@kenzierocks Thanks for the troubleshooting, that's a bastard of a thing to find so well done. @octarine-noise thanks I'll close the ticket.

octylFractal commented 10 years ago

@Mumfrey to be honest VisualVM was the thing that told me the deadlock was happening, it pretty much yelled that at my face.

Mumfrey commented 10 years ago

@kenzierocks lol, well at least you had the time to set everything up and test it. I'm so swamped at the moment trying to process just my own updates that it would have had to wait a while until I had time to sit down and diag it myself.