JanSeliv / CustomShapeButton

Open-source plugin that allows to make buttons of any shape in UE5.4
MIT License
80 stars 16 forks source link

random crash with this plugin #13

Closed pipi0425 closed 3 months ago

pipi0425 commented 4 months ago

Hi, your plugin is great and functions perfectly in most cases.

However, I just encountered some random crashes of the editor. When testing in PIE, sometimes, when mouse over my partly transparent hexagon shape button (using texture, not material), the engine just crashes, but when I restart the engine and test multiple times it does not reoccur, and a few hours later it crashes again. This gives me no confidence, not sure if it will crash in build. If you could kindly take a look if this is something in the code?

Unhandled Exception: EXCEPTION_ACCESS_VIOLATION reading address 0x00000000000addc3

UnrealEditor_CustomShapeButton!SCustomShapeButton::IsAlphaPixelHovered() [C:\...\Plugins\CustomShapeButton-main\Source\CustomShapeButton\Private\SCustomShapeButton.cpp:179]
UnrealEditor_CustomShapeButton!TBaseSPMethodDelegateInstance<1,SCustomShapeButton const ,1,bool __cdecl(void),FDefaultDelegateUserPolicy>::Execute() [C:\...\UE_5.4\Engine\Source\Runtime\Core\Public\Delegates\DelegateInstancesImpl.h:281]
UnrealEditor_CustomShapeButton!SlateAttributePrivate::TSlateAttributeBase<SWidget,bool,SlateAttributePrivate::FSlateAttributeNoInvalidationReason,TSlateAttributeComparePredicate<TEqualTo<void> >,0>::FSlateAttributeGetterWrapper<SlateAttributePrivate::TSlateA() [C:\...\UE_5.4\Engine\Source\Runtime\SlateCore\Public\Types\Attributes\SlateAttributeBase.inl:585]
UnrealEditor_SlateCore
UnrealEditor_SlateCore
UnrealEditor_SlateCore
more UnrealEditor_SlateCore here

I noticed that in SCustomShapeButton.cpp around line 179, you did check IsValidIndex, but in my case, exception access violation still triggers.

Does this have anything to do with multiple buttons close to each other and potentially overlap? My hex-shape buttons form a hex grid pattern.

p.s. I just checked the other closed issue and verified: texture: NoMipmaps texture group: UI never stream compression: vector displacement map RGBA8 and texture size 444*512, power of 2.

Any suggestions?

Thanks,

JanSeliv commented 3 months ago

@pipi0425, thank you for raising this issue and for your interest in this plugin!

It’s challenging to pinpoint the exact cause since I haven't been able to reproduce it myself.

Trying to fix this, I've submitted a possible solution on the Develop branch just for you. Please download and test the fix: Link. It includes the changes compiled for UE5.4.2

Let me know if the crash is resolved. If it is, I will update the Main branch and Releases page. If the crash persists, please provide the new crash call stack and the log file from YourProject/Saved/Logs.

pipi0425 commented 3 months ago

Thanks for your response. I just tested and encountered crashes again.

Unhandled Exception: EXCEPTION_ACCESS_VIOLATION reading address 0x0000000000000000

VCRUNTIME140
UnrealEditor_CustomShapeButton!SCustomShapeButton::GetRawColors() [C:\...\Plugins\CustomShapeButton-main\Source\CustomShapeButton\Private\SCustomShapeButton.cpp:79]
UnrealEditor_CustomShapeButton!SCustomShapeButton::IsAlphaPixelHovered() [C:\...\Plugins\CustomShapeButton-main\Source\CustomShapeButton\Private\SCustomShapeButton.cpp:178]
UnrealEditor_CustomShapeButton!TBaseSPMethodDelegateInstance<1,SCustomShapeButton const ,1,bool __cdecl(void),FDefaultDelegateUserPolicy>::Execute() [C:\Program Files\Epic Games\UE_5.4\Engine\Source\Runtime\Core\Public\Delegates\DelegateInstancesImpl.h:281]
UnrealEditor_CustomShapeButton!SlateAttributePrivate::TSlateAttributeBase<SWidget,bool,SlateAttributePrivate::FSlateAttributeNoInvalidationReason,TSlateAttributeComparePredicate<TEqualTo<void> >,0>::FSlateAttributeGetterWrapper<SlateAttributePrivate::TSlateA() [C:\Program Files\Epic Games\UE_5.4\Engine\Source\Runtime\SlateCore\Public\Types\Attributes\SlateAttributeBase.inl:585]
UnrealEditor_SlateCore
UnrealEditor_SlateCore
a lot of lines of UnrealEditor_SlateCore here

What I observe:

  1. my button is in a user widget bp, and I use create widget node in another widget bp to spawn them and add as a canvas child, so it is spawned, not placed.
  2. This seems to happen when I have several buttons and my mouse move quickly between these buttons. ( I am just testing with a hex-shaped game of life minigame and plan to use it as a loading screen, p.s. I change render opacity of the button everytime the game of life steps, but I do not set it to zero and everytime the editor crashes seems to be related to mouse moving very fast over a lot of buttons, and no crash for clicks) $3E3VFW)7PA{$M2KA L_JSP
  3. Also notice: just now I encountered the crash twice, and both reading address 0x00...0, GetRawColors() from SCustomShapeButton.cpp:79. I just moved from Unity to UE less than one year so I don't know, is it possible that some functions get called at the end of frame or some time later and caused the "when I access it, it has been changed" type of bug? Sandbox.log

Any suggestions? Thanks a lot!

JanSeliv commented 3 months ago

@pipi0425, thanks for the quick response.

The issue seems complex and may be difficult to fix without debugging your project, as I've already tried all ideas. Your logs look fine.

Are you able to send me your project via any of the following?

This would help the most to find the issue. If you can't send the project, please share some screenshots or a video of your setup.

Alternatively, you could modify the Sample Project I sent you before to make it crash as in your own project and send it to me.

pipi0425 commented 3 months ago

Hi, Sorry I don't use telegram. I've sent the project to your email from peterzsy@outlook.com, based on your sample project. I've also attached the zip here in case you did not receive it. CustomShapeButtonSample_UE5-4-crash240617.zip

Thanks!

JanSeliv commented 3 months ago

@pipi0425, thank you for providing the Sample Project with your modifications. It was extremely helpful, along with your video and Readme, which allowed me to reproduce and debug the crash.

I don't have a fix yet. Each time I think the crash is resolved, it appears again after about ~10 minutes of testing.

I will keep you updated once I have a solution

JanSeliv commented 3 months ago

@pipi0425, the issue seems to be fixed now, see the video, where I'm testing the fix for a few minutes: https://github.com/JanSeliv/CustomShapeButton/assets/20540872/7903140d-756b-42f5-8408-695867db66a2

Please download and test the Sample Project with included fix: CustomShapeButtonSample_UE5-4-crash240617.zip

Let me know if it works for you or still crashes

pipi0425 commented 3 months ago

@JanSeliv Hi, thanks for your quick response. I just tested it and also copied to my original project to test. At this moment, I do not see any problems or crashes, so I think this might have been fixed.

Just curious, I noticed your most recent commit used weakptr instead, what was causing this crash?

Again, thanks so much for your help!

JanSeliv commented 3 months ago

@pipi0425, thank you for confirming the fix!

Just curious, I noticed your most recent commit used weakptr instead, what was causing this crash?

Regarding the solution itself [commit], in your crash call stack, the error was EXCEPTION_ACCESS_VIOLATION. This happens when a pointer references an object that no longer exists. To fix it, I bound the IsAlphaPixelHovered function differently: with a lambda+weakptr pointer instead of a raw bind as before, to ensure it only runs if the Slate widget object is still valid before calling IsAlphaPixelHovered.

JanSeliv commented 3 months ago

I submitted the fix to the Main branch and updated the Releases page, so it's included now for everyone.

Closing the issue as done per confirmation above.

GdevPT commented 3 months ago

Hi, seems like this issue is still present after all, I get it the most often hovering images with a lot of transparency spots

JanSeliv commented 3 months ago

@GdevPT could you please repeat your setup/textures in my Sample Project from Releases page, so it starts crashes here as well and send me it back as author did above? Video also will help a lot. So I can reproduce this issue on my own and try to fix