Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

(De)activating particle system causes crash

I have been exploring Unreal with C++ in a toy project, but this issue is driving me insane. For some reason calling either Activate() or Deactivate() on a UParticleSystemComponent crashes the editor.

In an APawn child class header, I have the following declaration:

 UPROPERTY(Category = Particle, VisibleDefaultsOnly, BlueprintReadOnly, meta = (AllowPrivateAccess = "true"))
 class UParticleSystemComponent* EngineFlameL;

The following is a part of the constructor in the corresponding .cpp file:

 // Structure to hold one-time initialization
     struct FConstructorStatics
         ConstructorHelpers::FObjectFinderOptional<UStaticMesh> CollisionMesh;
         ConstructorHelpers::FObjectFinder<UParticleSystem> EngineFlameL;
             : CollisionMesh(TEXT("/Game/SB/Meshes/fighter/fighter_collider")),
     static FConstructorStatics ConstructorStatics;
     // Create static mesh components
     CollisionMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("CollisionMesh0"));
     RootComponent = CollisionMesh;
     // attaching particle systems
     EngineFlameL = CreateDefaultSubobject<UParticleSystemComponent>(TEXT("EFL0"));
     if (ConstructorStatics.EngineFlameL.Succeeded()) {
     EngineFlameL->Template = ConstructorStatics.EngineFlameL.Object;
     EngineFlameL->ActivateSystem();  // This line causes a crash for some reason

None of the above variables are referenced anywhere else in the code. Everything works fine when the ActivateSystem() line above is commented out. The particle system is then rendered and fully functional.

If an ActivateSystem() or DeactivateSystem() is called anywhere in the constructor or Tick() functions, compilation will be successful, but the editor will crash as soon as I press the "Play" button. Afterwards, it will also crash instantly upon an attempted (re)start. The editor used to give a crash-report window, but I did not have the required debugging symbols for generating a proper error message. After downloading the symbols, the crash-window does not appear at all anymore.

I can get the project working again after removing the de(activation) calls and recompiling. I have tested this for different particle systems, but the problem persists for all of them.

Am I missing something obvious? Perhaps some kind of initialization? Calling InitializeSystem() first does not seem to help (but does not give issues, so the pointer seems to be valid).

Any help would be hugely appreciated!

Product Version: UE 4.20
more ▼

asked Nov 13 '18 at 10:47 PM in C++ Programming

avatar image

1 1 2

avatar image Brian Johnstone Nov 14 '18 at 09:50 PM

Now that you have the debug symbols for the engine downloaded do you have a proper stack trace when the crash occurs?

avatar image Vinkon Nov 15 '18 at 08:52 PM

For some reason I cannot reply to your post, Brian, so I am replying here:

The crash window has stopped showing up after I got the symbols. The log in the project's Saved/Logs contains the following:

 [2018.11.15-20.25.18:386][583]LogBlueprintUserMessages: Early PlayInEditor Detection: Level '/Game/FlyingCPP/Maps/FlyingExampleMap.FlyingExampleMap:PersistentLevel' has LevelScriptBlueprint '/Game/FlyingCPP/Maps/FlyingExampleMap.FlyingExampleMap:PersistentLevel.FlyingExampleMap' with GeneratedClass '/Game/FlyingCPP/Maps/FlyingExampleMap.FlyingExampleMap_C' with ClassGeneratedBy '/Game/FlyingCPP/Maps/FlyingExampleMap.FlyingExampleMap:PersistentLevel.FlyingExampleMap'
 [2018.11.15-20.25.18:416][583]LogPlayLevel: PlayLevel: No blueprints needed recompiling
 [2018.11.15-20.25.18:540][583]PIE: New page: PIE session: FlyingExampleMap (Nov 15, 2018, 8:25:18 PM)
 [2018.11.15-20.25.18:541][583]LogPlayLevel: Creating play world package: /Game/FlyingCPP/Maps/UEDPIE_0_FlyingExampleMap
 [2018.11.15-20.25.18:581][583]LogWindows: Windows GetLastError: The operation completed successfully. (0)
 [2018.11.15-20.26.19:266][583]LogWindows: Error: === Critical error: ===
 [2018.11.15-20.26.19:266][583]LogWindows: Error: 
 [2018.11.15-20.26.19:266][583]LogWindows: Error: Assertion failed: GetWorld() [File:D:\Build\++UE4\Sync\Engine\Source\Runtime\Engine\Private\Particles\ParticleComponents.cpp] [Line: 5842] 
 [2018.11.15-20.26.19:266][583]LogWindows: Error: 
 [2018.11.15-20.26.19:266][583]LogWindows: Error: 
 [2018.11.15-20.26.19:266][583]LogWindows: Error: 
 [2018.11.15-20.26.19:266][583]LogWindows: Error: 
 [2018.11.15-20.26.19:342][583]LogExit: Executing StaticShutdownAfterError
 [2018.11.15-20.26.20:238][583]LogWindows: FPlatformMisc::RequestExit(1)
 [2018.11.15-20.26.20:296][583]Log file closed, 11/15/18 20:26:20

I have not been able to find any other logs. Is there perhaps some other place I should be looking? Thanks for your help.

avatar image Brian Johnstone Nov 15 '18 at 08:57 PM

Since you have the debug symbols installed you'll want to run the project from visual studio. Are you actually running the editor through visual studio while it is debugging? Visual studio should be able to catch the crash as it happens and provide information about the stack and memory at the moment of the crash.

avatar image Vinkon Nov 15 '18 at 10:13 PM

This is the top of the call stack when the exception is thrown:

 >    UE4Editor-Engine.dll!UParticleSystemComponent::DeactivateSystem() Line 5842    C++
      UE4Editor-ace-6854.dll!AacePawn::AacePawn() Line 77    C++
      UE4Editor-CoreUObject.dll!StaticConstructObject_Internal(UClass * InClass, UObject * InOuter, FName InName, EObjectFlags InFlags, EInternalObjectFlags InternalSetFlags, UObject * InTemplate, bool bCopyTransientsFromClassDefaults, FObjectInstancingGraph * InInstanceGraph, bool bAssumeTemplateIsArchetype) Line 3156    C++
      UE4Editor-CoreUObject.dll!FDuplicateDataWriter::GetDuplicatedObject(UObject * Object, bool bCreateIfMissing) Line 138    C++
      UE4Editor-CoreUObject.dll!FDuplicateDataWriter::operator<<(UObject * & Object) Line 65    C++
      [Inline Frame] UE4Editor-Engine.dll!operator<<(FArchive &) Line 92    C++
      UE4Editor-Engine.dll!operator<<(FArchive & Ar, TArray<AActor *,FDefaultAllocator> & A) Line 1109    C++
      UE4Editor-Engine.dll!ULevel::Serialize(FArchive & Ar) Line 316    C++
      UE4Editor-CoreUObject.dll!StaticDuplicateObjectEx(FObjectDuplicationParameters & Parameters) Line 2094    C++
      UE4Editor-CoreUObject.dll!StaticDuplicateObject(const UObject * SourceObject, UObject * DestOuter, const FName DestName, EObjectFlags FlagMask, UClass * DestClass, EDuplicateMode::Type DuplicateMode, EInternalObjectFlags InternalFlagsMask) Line 2000    C++
      UE4Editor-UnrealEd.dll!UEditorEngine::CreatePIEWorldByDuplication(FWorldContext & WorldContext, UWorld * InWorld, FString & PlayWorldMapName) Line 3656    C++
      UE4Editor-Engine.dll!UGameInstance::InitializeForPlayInEditor(int PIEInstanceIndex, const FGameInstancePIEParameters & Params) Line 245    C++

alt text

It seems there is a problem with getting the world pointer in DeactivateSystem().

capture.png (112.7 kB)
avatar image Brian Johnstone Nov 19 '18 at 02:51 AM

Does this only happen if you call Deactivate in the constructor? What happens if you wait to deactivate the system in the actor's BeginPlay function? I think what is happening is the CDO does not have any sort of initialized world when it gets called.

avatar image Vinkon Nov 26 '18 at 12:35 AM

(De)activating the system in the actor's BeginPlay function works like a charm. Thanks for your help!

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

The crash occurred because (de)activating particle systems requires the world to be initialized. This could not be guaranteed at the time my actor's constructor was called, which caused an assertion to fail. As suggested by Brian, calling the (de)activation later on (in the actor's BeginPlay function) fixes the problem.

more ▼

answered Nov 26 '18 at 12:43 AM

avatar image

1 1 2

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question