Ribbon Trail error in cooked and Xbox One builds

This is using 4.7.6

Here is an example of the game working on PC, and not cooked. Notice the ribbon trails that show the flow of the water:

Here is what it looks like on a cooked build and also Xbox One builds. Notice the trails that are straight lines and seem to connect to random points.

The particle system is pretty simple. It’s just an invisible system that has particles that travel down the river, and then the particle trails that follow these. I spent some time looking through the code trying to find what would cause it, but the trails were pretty complex and I didn’t figure it out right away.

Any information would be appreciated!

This also happens for games cooked in debug game mode. So, it appears it’s the cooking of the content and not the mode the code was compiled in. Note the trails that all appear to be coming from a single point in the lower left.

I removed a custom particle velocity component I wrote, just to make sure that wasn’t the problem. I replaced it with a velocity component that simply moved down Y at -1000 m/s. Anyway, same thing.

I have verified that the same problem occurs if you cook the data and then run the game in a Debug build.

OK! Figured it out. FParticleRibbonEmitterInstance::ResolveSourcePoint() was accessing an out of bounds particle in the SourceEmitter. It was calling SourceEmitter->GetParticleDirect(0) when SourceEmitter didn’t have any active particles.

My fix was to add:

                if (SourceEmitter->ActiveParticles == 0)
                {
                    return false;
                }

After the null check on SourceEmitter. It may not be the most correct fix, but it’s doing what I need right now, and I’m under a lot of time pressure!