Neos-Metaverse / NeosPublic

A public issue/wiki only repository for the NeosVR project
195 stars 9 forks source link

Over time dev tip selection takes longer and longer #821

Closed Earthmark closed 4 years ago

Earthmark commented 4 years ago

I've noticed this in many worlds, after a few hours dev tool select starts to cause the user who made the selection to hang for a few seconds every time they select something. I can get some diagnostics next time it comes up if ya need, I get a feeling this is a known thing but in case it doesn't have a bug yet!

H3BO3 commented 4 years ago

I've noticed hangs when trying to select things sometimes too, doesn't seem to be bound to the tool, since I can join a world that's been running for a while, get out a new tooltip, and once I try to select something the program hangs for a few to several seconds.

shiftyscales commented 4 years ago

Hmm- I'd imagine it's at least in part due to the swelling complexity of the datamodel over time. I wonder though- is this isolated to just that specific instance?

I would imagine that saving the world in its current state, closing the session, and reopening another could likely help/would support that suspicion- unless it's something lower-level in which case, you should be able to test it out by going into other sessions and seeing if that still occurs, @Earthmark.

Earthmark commented 4 years ago

It's the specific instance and reloading the world is the common way to fix it. This is a well known bug to the community, and the well known fix is save and reload the world.

shiftyscales commented 4 years ago

I'd imagine that is something that could likely be improved by underlying datamodel optimizations including others with the 'performance' label, then. Otherwise, it's something that will need to be profiled to know with any certainty. E.g. via the debug branch.

Do you know if it also occurs for worlds that don't really have anything going on in them for a prolonged time? Or is it specific to sessions with a lot of activity, @Earthmark?

If @Frooxius has any insight/thoughts, I'd appreciate them too.

Earthmark commented 4 years ago

I can hook up my profilers and find hot paths if it happens again, if you'd rather the debug branch specifically I can do that but it normally takes a few hours for it to occur.

I'm not sure on if it happens when nothing else is happening, I'll try to keep an eye out for that.

shiftyscales commented 4 years ago

More information as to what causes the issue in the first place would help a lot in figuring out how it could be dealt with. Either approach would work, but for now, keeping an eye out on it would be nice thanks, @Earthmark.

Frooxius commented 4 years ago

The dev tooltip uses multiple ways to select an object. It tries to do a physics query, but not everything has a collider, so one of the things it does it loop through all of the objects in the scene and check distance for each one.

Normally this is fast enough to not be a huge issue, but it might be causing pauses here. How big are the scenes when this is happening? Does it persist if you save the world, restart Neos, start it again and select?

It might not be the tool itself, but an overhead of GC due to heavy allocations or something like that, because even with huge worlds it shouldn't be taking seconds.

Earthmark commented 4 years ago

It does not persistent over a world save, saving and reloading is a way to fix the problem right now. After the save selecting is instant again.

If it happens again to me I'll attach a debugger and send a summary your way, I get a feeling this may be a hot path thing or such but we'll see.

I will say the time can go up to over 10 seconds, I don't think it's an issue of the size of the world, I do do cleanups when this happens but the world still has the issue. Also I'm highly suspect this is related to the number of active assets, the number of objects in the world is still countable, not really anywhere near what would I'm guessing be like trillions of objects to hit 10 seconds of iterating delay?

Frooxius commented 4 years ago

Hmm that is definitely odd. The code is always the same, but it's possible there's some external influence. Without a profiler trace it'll be harder to determine what it is though, unless there's a good way to reliably reproduce it. I'd need to make a build instrumented for profiling to get good data.

The number of objects and assets remains more or less the same when you save, so that shouldn't matter. It's definitely not trillions of objects, that's way too much for a scene. Usually scenes have thousands to dozens of thousands.

Frooxius commented 4 years ago

Based on log from Shifty, this seems to be happening due to thousands of exceptions being thrown. Unfortunately the actual exception wasn't logged, I've added the logging in 2020.8.3.1234. Please send logs once you encounter this again!

Ducky07 commented 4 years ago

Me and Enverex encountered it earlier today, I hope this helps. (It's a pretty big log but the actual issue started occurring for me in the last 15 minutes or so. DESKTOP-9UGUIMF - 2020.8.7.1059 - 2020-08-09 16_29_55.log

Frooxius commented 4 years ago

Thanks that helps a lot! Looks like it's happening because of orphaned slots (parts of hierarchy that end up with no parent). Fixing that issue will fix this as well.

H3BO3 commented 4 years ago

Are orphaned slots really being generated and kept at that high of a rate? I've seen those visible a few times with weird scenarios with avatar switching or user regen, where the avatar slot gets orphaned and left behind, visible in the world with no parent. Is there a downside to automatically cleaning those up?

Frooxius commented 4 years ago

They should automatically be cleaned up (or rather reset to either last good parent or under world root), but for some reason they aren't.

ukilop commented 4 years ago

perhaps related to when i sometimes see slots above the root slot when inspecting root? (edit: damn that discord bot is fast i watched it post as i hit it)

Frooxius commented 4 years ago

When are you seeing those? There's not really mechanism for that, so that sounds more like UI bug or something.

ukilop commented 4 years ago

ill have to catch it next time i see it

Frooxius commented 4 years ago

I've got a fix coming!

Frooxius commented 4 years ago

Ok should be fixed in 2020.8.10.1195. Let me know if it still occurs!