Download

Scary Physics Crash, Ending Physics on SMA + SetActorTransform = Crash

Dear Friends at Epic,

I am posting this here because it is a scary issue indicating some underlying issues that did not exist in 4.0.2.

This is an issue for 4.1 that did not exist in 4.0.2


**Reproducing the Crash**

1. Spawn Static Mesh Actor into world, from SMA extending class
2. Set this spawned mesh to simulate physics,
3. Then on key press or some other event, do the following in same tick / same function:

4. end physics
5. Set Actor Transform

**It causes a crash to desktop!**

**This exact same code worked just fine in 4.0.2!**

In my case I am doing 4 and 5 from within the SMA-extending class itself

More Info

Ending Physics or SetActorTransform, but not both (in same tick),

does not cause a crash.

Which just makes it even more disconcerting to me :slight_smile:


**Code**



```

//End Physics
StaticMeshComponent->SetSimulatePhysics(false);
 
//Restore Editor Pos
SetActorTransform(Vibes.RedVibes.VictoryTransform);

```



**
Crash Abbreviated**



ServerAcknowledgePossession_Implementation VictoryWarriorSpiritBP_C_0
[2014.04.26-15.27.33:142] 97]LogThreadingWindows:Error: Runnable thread TaskGraphThread 0 crashed.
[2014.04.26-15.27.33:142] 97]LogWindows: === Critical error: ===
 
 
[2014.04.26-15.27.33:142] 97]LogWindows: Fatal error!
 
 
Crash in runnable thread TaskGraphThread 0
[2014.04.26-15.27.33:142] 97]LogExit: Executing StaticShutdownAfterError
[2014.04.26-15.27.33:142] 97]LogWindows:Error: Error reentered: Runnable thread TaskGraphThread 0 crashed.
[2014.04.26-15.27.33:142] 97]LogWindows:Error: HandleError re-entered.
[2014.04.26-15.27.33:142] 97]LogWindows: FPlatformMisc::RequestExit(1)
[2014.04.26-15.27.33:142] 97]Log file closed, 04/26/14 11:27:33


**Workaround Solution = 0.01 Second Timer**

What I used to do in same function / tick I now have to separate out by a 0.01 second timer.

1. Disable physics and start timer


```

StaticMeshComponent->SetSimulatePhysics(false);

GetWorldTimerManager().SetTimer(this, 
  &AVictoryWall::PHYSICSCRASH_DoTransformUpdateNow, **0.01**, false);

```



2. Timer then calls SetActorTransform()


```

void AVictoryWall::PHYSICSCRASH_DoTransformUpdateNow()
{
	SetActorTransform(Vibes.RedVibes.VictoryTransform);
}

```



The Big Picture

I have an in-game level editor, when game starts, physics is turned on and the SMA goes wherever it goes,

when player exits in-game mode, the physics is ended on the SMA and SetActorTransform is called to restore it to its Editor Position

This scenario being done over and over is how I encountered this bug.

The crash happens on the very first attempt however, it does not take multiple attempts.


AnswerHub version of this post, with full Log
https://answers.unrealengine.com/questions/35348/ending-physics-and-setting-transform-in-same-tick.html


Thanks!

Rama

PS:I am double posting on answerhub and here because this is a scary issue to me, it needs to be addressed ASAP or else it will cause further destabilization and bugs people may not figure out for awhile

Bump in preparation for monday morning in UK

:slight_smile:

Rama

Let me know Epic when you’ve seen this and are on it and I will stop bumping it.

I feel this is extremely important :slight_smile:

:slight_smile:

Rama

We’ve seen it! Thanks Rama :stuck_out_tongue:

Thanks James and Ori!

The issue is currently unreproduceable for reasons I cannot fathom (Yay!).

https://answers.unrealengine.com/questions/35348/ending-physics-and-setting-transform-in-same-tick.html

As a note to others:

If you have any issues you think are related to async scene, try toggling it on and off a couple of times (Editor->Edit->ProjectSettings->Physics->Advanced View).

That is the only thing I did that seems to have resolved the crash.

in 4.2.1 I have a similar crash to desktop if I get two physics actors of same class, touch in game I want to switch the physics off (set Physics simulation - false) - this is using blueprints, and happens everytime. I may be doing something a bit hacky so will test further but thought I’d write it here so others could check. I will try a delay node see if it helps like in the C++ code.

Update: The crash only happens with CCD turned on for the mesh! With it off and ASync scene on it’s fine. Possibly with ASync scene off also, will need to test further. It could just be my hacky blueprinting, I guess it needs to check that physics have stopped being simulated before attempting to remove them??