Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
StackOverflowException on large spline network
#1
Exclamation 
Hi

I'm building a large network of connected Curvy splines and have run into a fatal issue when building the scene.

My current test scene has 1242 individual curvy splines, with many connections tying them together, and when I try to build the level, Unity crashes silently with several "Failed to postprocess stacktrace StackOverflowException" in the editor log.

The editor log does not point to anything Curvy related, but removing the splines allows me to build the scene.

The scene runs without issue in the editor window.

Any suggestions?

Best regards
Christian
Reply
#2
Upon further investigation it seems that the issue is caused by spline connections, as creating the spline network without any connections lets me build the scene as well.
Reply
#3
(03-15-2016, 01:33 PM)Nalle Wrote: Upon further investigation it seems that the issue is caused by spline connections, as creating the spline network without any connections lets me build the scene as well.

Hi Christian,
how many connection gameobjects you have in the _CurvyGlobal_ folder?
and do you animate any of the spline points ?

It's interesting to know, because I have also heavy issues because of the permanently enabled animation feature all splines.

Thanks
(Henry Ford) Each hour more of searching is each hour less of your live time.

Reply
#4
Hi Roger

I have 2484 connections to be precise. I'm actually not sure if my stack overflow issue is specific to Curvy or Unity itself. I first tried adding a custom connection component to each CurvySplineSegment (i.e. control point), but the result here was the same with the scene playing fine in the editor but causing a StackOverflowException when building.

I have now resorted to creating a dictionary on scene load with an entry for each control point in the scene. For each control point in the dictionary I have a simple wrapper class holding references to control points that should connect to this control point. I use the InstanceID of each control point to perform a fast lookup in the dictionary whenever I reach a control point, and this is working well for me so far.

I'm not exactly sure what you mean by "permanently enabled animation feature", but because I have so many splines in the scene I was having performance issues from the CPU overhead of all the splines having their update methods invoked each frame. Since all splines in my scene are static this overhead is not necessary.

To remove the update calls I've wrapped the three update methods in CurvySpline.cs in a conditional define so that they are only run in the Unity editor (i.e. #if UNITY_EDITOR). On scene load I then manually call update on each spline a single time to initialize them which allows the SplineController to navigate the spline network.

If the Curvy authors are reading this, It would be nice with official support for this last step of eliminating the update calls for static splines, to avoid having to implement the workaround whenever the package is updated Smile

Best regards
Christian
Reply
#5
(03-17-2016, 01:03 PM)Nalle Wrote: To remove the update calls I've wrapped the three update methods in CurvySpline.cs in a conditional define so that they are only run in the Unity editor (i.e. #if UNITY_EDITOR). On scene load I then manually call update on each spline a single time to initialize them which allows the SplineController to navigate the spline network.

I used a similar work around on CurvySpline.cs.

Additionally: This make sure the SplineControllers start to work
Code:
void Start() {
            doUpdate();
        }
}

Each of the UpdateXX Method includes:.
Code:
void Update() {
(!CheckTransform ) return;
........
}


Disabling CheckTransform on any spline separately eliminates the CPU overhead drastically.
But this is not all btw. The CurvyConnection Update() cause another trouble on my configuration because of the Update() method too.

Code:
    public void Update() {
            bool syncPos = TTransform.position != transform.position;
            bool syncRot = TTransform.rotation != transform.rotation;
            if (syncPos || syncRot) {
                SynchronizeINTERNAL(transform);
            }
        }

This seems, it's used to hold the connection points over each other. Therefore I wrote about "permanently animated feature". All this required updates methods are use to perform changes or animations if they eventually used. If using some splines only, it doesn't matter. Try to use #if UNITY_EDITOR on CurvyConnection.Udpate() Perhaps this change the call stack resizement for the Build previously.
(Henry Ford) Each hour more of searching is each hour less of your live time.

Reply
#6
Ok,

unchecking CheckTransform for all splines definitely saves a lot of time. Using conditionals definitely is a way to get rid of the calls to Update/LateUpdate/FixedUpdate. I'm thinking of a good way to add that to the package.

If you still get the Stack Overflow when not using CurvyConnection at all, I'd say it's not Curvy related, but unless knowing for sure everything is possible. What build target are you using?

The only possible reason I can think of related to CurvyConnection is that the connection changes it's position/rotation and the spline by error forces a sync of the connection again, resulting in a loop.

If you want, send me an export (with examples and all unneeded stripped) to jake<at>fluffyunderware<dot>com, I'll take a try to find the cause of the stack overflow then.
Reply
#7
Please post your findings.
(Henry Ford) Each hour more of searching is each hour less of your live time.

Reply
#8
Hi Jake

Build target is Android.

The stack overflow only occurs when I am using CurvyConnections, I think the possible reason you listed could very well be the source of the stack overflow.

As I wrote, I've solved it by maintaining my own connections at runtime, but I'll see if I can't find the time to send you a stripped example scene for debugging.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Generate Mesh Spline from GameObject processor 4 147 10-01-2020, 11:00 AM
Last Post: _Aka_
  Generated mesh using bezier spline is not following the path accurately processor 3 265 08-25-2020, 04:39 PM
Last Post: _Aka_
  Best practice when Instantiating game object with spline GenericJoe 1 215 08-22-2020, 02:40 PM
Last Post: _Aka_
  How to calculate curvature of spline jh092 3 351 08-01-2020, 04:51 PM
Last Post: _Aka_

Forum Jump: