Set Particle Component's TickEvenWhenPaused to true, then run the game, then SetGamePaused to true, then crash

The actor’s setup is like this:

102271-particle_crash.png

Then you can call SetTickableWhenPaused(true) for the particle component:

102273-particle_crash_2.png

Then call this some where some time:

102274-particle_crash_3.png

Then crash.


We’ve examined the call stack and suspecting it’s a bug. The TickTaskManager clears the TickFunction->TaskPointer first then calls ExecuteTick(), however when during ExecuteTick(), tick function uses TaskPointer so it crashes.

Code samples are below:

TickTaskManager.cpp // the calling site, call ExecuteTick() then goes to particle component.

for (TSet<FTickFunction*>::TIterator It(AllEnabledTickFunctions); It; ++It)
{
	TickFunction = *It;
	TickFunction->TaskPointer = nullptr; // this is stale, clear it out now
	if (TickFunction->bTickEvenWhenPaused && TickFunction->TickState == FTickFunction::ETickState::Enabled)
	{
				TickFunction->TickVisitedGFrameCounter = GFrameCounter;
				TickFunction->TickQueuedGFrameCounter = GFrameCounter;
				TickFunction->ExecuteTick(InContext.DeltaSeconds, InContext.TickType, ENamedThreads::GameThread, FGraphEventRef());

ParticleComponent.cpp // crash is here, GetCompletionHandle() failes inside.

{
	SCOPE_CYCLE_COUNTER(STAT_UParticleSystemComponent_QueueAsync);
	AsyncWork = TGraphTask<FParticleAsyncTask>::CreateTask(nullptr, ENamedThreads::GameThread).ConstructAndDispatchWhenReady(this);
#if !WITH_EDITOR  // we need to not complete until this is done because the game thread finalize task has not beed queued yet
	ThisTickFunction->GetCompletionHandle()->DontCompleteUntil(AsyncWork);
#endif
}

Hey -

When I added a ParticleSystemComponent (MyPSC) to my actor class and set MyPSC->SetTickableWhenPaused(true); I did not receive a crash when I tried to play in the editor. Can you provide the setup where you’re setting bTickableWhenPaused as well as the callstack and log files from the crash for additional information?

Ah, sorry that I didn’t mention you can’t test this in PIE, since PIE would lead to the non-async part of particle component’s Tick so it would never crash. As you can see the posted code snippets are specific to “#if !WITH_EDITOR”.

I took the sample project I had and tried to test it in a Standalone window as well as a packaged game and did not get a crash. Can you add the callstack and log files from the crash as well as the steps for your setup to help me test on my end?

Hey -

We have not heard back from you in a few days, so we are marking this post as Resolved for tracking purposes. If you are still experiencing the issue you reported, please respond to this message with additional information and we will follow up.

Cheers

Ok, the call stack is below

Assertion failed: TaskPointer [File:C:\dev\VR\Game\Engine\Source\Runtime\Engine\Private\TickTaskManager.cpp] [Line: 1702]
[Callstack] 0x02c5ba67 - UParticleSystemComponent::TickComponent(float, ELevelTick, FActorComponentTickFunction*)
[Callstack] 0x026a812a - FActorComponentTickFunction::ExecuteTick(float, ELevelTick, ENamedThreads::Type, TRefCountPtr<FGraphEvent> const&)
[Callstack] 0x031d6495 - FTickTaskLevel::RunPauseFrame(FTickContext const&)
[Callstack] 0x031cfd5c - FTickTaskManager::RunPauseFrame(UWorld*, float, ELevelTick)
[Callstack] 0x02ab772f - UWorld::Tick(ELevelTick, float)
[Callstack] 0x028ef36a - UGameEngine::Tick(float, bool)
[Callstack] 0x00418827 - FEngineLoop::Tick()
[Callstack] 0x0042aba4 - tchar_main(int, wchar_t**)
[Callstack] 0x0042a431 - main
[Callstack] 0x03bdc82b - _start

The setup is fairly simple, like this:

102271-particle_crash.png

And actually we’re having this issue in packaged game, but I’m not sure if this problem is only for PS4.

Hi, please check the comment above, thanks!

Just to recap to confirm if my setup is correct, please let me know if you are doing the following (or what you are doing differently)

  • Create new class based on Actor
  • Add UPROPERTY (EditAnywhere, BlueprintReadWrite, Category = Test) UParticleSystemComponent* MyPSC; to header
  • Add MyPSC = CreateDefaultSubobject < UParticleSystemComponent>(TEXT("MyPSC")); and MyPSC->SetTickableWhenPaused(true); to the constructor
  • After compiling the code, in the editor you add a particle system to the component in blueprints and place an instance in the level
  • Package and run the packaged game

From my understanding, it is here that you are getting a crash? If this is accurate, can you let me know if you get a crash in a new sample project while running the packaged game on Windows. If so, please add the sample project to help identify the issue. If you do not crash with these steps on Windows, can you confirm if you do get a crash on PS4? If you are doing something different or I’ve missed something in my steps, please let me know exactly what your setup looks like and exactly what you are doing that leads to the crash.

Hi :

The only difference of my setup is that I made my whole actor in Blueprint, otherwise I think mine is the same as yours. And after reading my own post again, I found that I made a critical mistake. You have to pause the game to trigger the crash, I don’t know why I missed describing this in my post…I’m truly sorry for that! I’ll edit the post title and content.

So the steps are, make this actor with particle component, run the packaged game, then pause the game (you can make a keyboard event to execute “SetGamePaused(true)”, of course) and wait the assertion comes up.

Hi, please check the new comment and edited post, thanks T.T

Hey -

I was able to reproduce the crash after pausing the game and have entered the bug UE-34486 for further investigation. You can view the public tracker for this issue here: Unreal Engine Issues and Bug Tracker (UE-34486)

Cheers

Great, thanks!

This issue is blocking me. Once you find a fix, could you please post it here so I can modify the code without waiting for 4.14 ?
Thanks