Changing script properties used by ammoWidget causes client to crash

Describe the bug:

The crosshairScript uses the following properties from a held entity:

  1. currentShotsInClip
  2. crosshairType
  3. localTarget
  4. hasLimitedClip
  5. shotsPerClip
  6. ammoTemplate

It accesses these properties in a LocalOnTick function, and subsequently sends to them to the ammoWidget properties (new with cursed galleons).

If you change these properties externally, the entire game client will crash.

How do you cause this bug?

I’ve created a repro here, simply walk into the green square: Crayta

If you want to create it yourself:

  • Create a blank game
  • Add the inventory package
  • Add the gun package
  • Add the crosshair package
  • Add the player templates to the player
  • Add the user templates to the user
  • Set the gun template as the default item in the userInventory defaults script
  • Set the inventoryViewScript’s OnHeldEntity event to send the held entity to the crosshairScript’s SetHeldEntity method
  • Put a trigger in the world, and add a script to the trigger that simply does this:
function BugScript:OnTriggerEnter(player)
	player.inventoryViewScript.properties.heldEntity.gunScript.properties.currentShotsInClip = 300
end
  • Walk into the trigger.

Which platform: PC

Your Crayta username: Cereal

Game seen in (including “Hub” or “Editor for XYZ”): Editor

How regularly do you see this? (E.g. 2/3 times - please try 3 times if possible): 100% reproducible

Time + date seen: April 7 2022

Version number (found in Help tab in Settings): 0.f1.133.119466

(PC only) hardware specs (upload dxdiag file if possible - Open and run DxDiag.exe):

Remember!
The more information you provide, the more likely it is that this bug can be fixed quickly! Also, if this was discussed in Discord / Reddit / elsewhere, it might help to include a screenshot of that discussion!

3 Likes

Hey there @Cereal ! :sun_with_face:

Thank you for the very detailed bug report! Again thank you for providing us a link to a game that we can evaluate the situation. I have opened up a ticket for our internal team to investigate the issue further.

Have a wonderful weekend :v:

Hi,

Thanks for the bug report, and apologies for the delay in looking into this issue for you.

I believe we’ve already come across an issue like this before and have escalated it with the Coherent Labs team to put in a fix for the underlying issue in their SDK.

The crash occurs due to the size of the html element for the ammo display becoming too large due to the values being passed to it being out of range. In this case, it looks like the gun is being asked to hold more ammo than the clip size, which results in some logic in the widget calculating quite a large width percentage for the linear gradient used to display the ammo.

data-bind-style-width=“(100 * {{properties.ammo}}/{{properties.ammoFull}}) + ‘%’”

becomes:

data-bind-style-width=“(100 * 300/30) + ‘%’”

becomes:

data-bind-style-width=“1000%”

This results in a large texture buffer being created for the linear gradient, which Gameface currently does not cap to a safe limit and therefore causes the crash you’re experiencing.

We should be able to update the ammo widget to sanitize the values being used to calculate the width, but in the mean time, if you ensure the values being set are in the correct range (e.g. ensure the shotsPerClip property is updated before setting currentShotsInClip to a higher value) then you should be able to avoid the crash until we can update to a future version of the Gameface SDK, which includes a code fix.

Hope this helps, and please let me know if you have any more questions.

Thanks,
-Chris

Hi Cereal, when the next update goes out could you please update your packages to the latest in the game you provided that crashes and let us know if this is resolved for you?

Hey. This issue should have been resolved as of the update yesterday (Patch Notes: Cybotanica Battle Pass!). If you could verify and mark this as fixed that would be great :slight_smile: