Dragging crafting queue icons while crafting can cause errors

Fairly repeatable bug here.

  1. Set up a queue of items to craft.
  2. When your crafter has put all the materials on his workbench and is pounding away to make the first item, click on any item icon and hold and drag it. When the crafter completes his current crafting job, you’ll get an error.
  3. For bonus errors: Drag the item icon to the start of the queue, but don’t release before the current crafting job is complete. You’ll get an additional two errors.


My guess is that the game creates a list when you click on the object to drag it. As you drag the icon around, it gets relevant information about the item that is currently directly after the dragged icon (so it can update the visuals on the fly). The moment the crafter deletes an entry, the list gets a null in it and errors out.

3 Likes

I know this sounds simple but I read this 10 times and I still got no idea what you are saying :confused:
By the way I love how you added a “bonus error” XD

That particular paragraph is more or less for my own entertainment (and so is the rest of this reply). I don’t really know how they’ve coded it, so I’m just taking a programmer’s stab at how the code could be written to generate that kind of error under those circumstances. I’ll try to explain it in a way that someone with no programming knowledge could understand (because I don’t know how much you know).

From the errors as they are written, it’s pretty clear that the code is trying to access an object which no longer exists. In the guts of the programming, the game must have a list of the various items in the crafting queue. That list is made up of of objects (nodes) that contain their own information, but the only information the list object has is its own name and the location of the first node in the list. Each node knows which object is before it (insertBefore) and after it (insertAfter), it’s own name (id) and at least what type of item is being crafted.

At the most basic level, when the list wants to find an item in the list, it simply goes to the first node, sees if that is the one it wants and if it isn’t, asks that node where the next node is. It repeats that operation until it either finds the item it wants or fails to find it in the last item. It can tell which is the last item because it’s insertAfter property will be empty.

The game takes that list and uses it to draw the icons on the screen in the correct order. So for every frame of graphics the game draws to the screen, it polls the list to see what the order is.

When you hold and drag an item in the queue, the game needs to know where you are trying to put that item so that it can draw the icons in the correct positions. Based on screen position, it knows to put the item in the first, second, third or fourth slot in the visible portion of the list and then figures out which item in the list it needs to insertBefore or insertAfter.

The problem comes when your crafter is puttering away and removes an item from the list at the same time as you are messing with it. When the crafter finishes crafting an individual item, it would remove that item from the front of the list.

But does the code that the program uses to handle moving the position of the held item work directly with that original list? It does and it doesn’t. It is given a pointer to the start of the list. A pointer is simply a variable that tells you where something is. From that, you can find the rest of the list by following the pointer to the next item and then the next all the way to the end.

But what happens when the crafter deletes the first item in the list? The variable that the mouse code uses to tell it where the start of the list is now points at an object that no longer exists! An object that no longer exists is said to be null. The first time the mouse code knows about it is when it tries to get the name (id) of the first item on the list. It fails to find the name and generates an error report: “Cannot read property ‘id’ of null”. The traceback tells us (through the magic of informative function names!) that this happens when trying to draw the crafting window on the screen (show_workshop.js) and that is handled by a series of specific functions in the jquery-ui code.

Now, if you were only dragging your mouse to a position after the first item in the list, that’s all you’d see. But when you are in the first position, you get a pair of errors that duplicate each other. Again, I can only guess based on the errors given and the way lists usually work.

Usually, if you want to put a new item in a list it is called an insert. You have one function for inserting before a specified item and one for inserting after a specified item. If we want to insert an item before an existing item, we need to know which item previously came before that existing item (so we can tell it who the new “next” item is). The error we see is for failing to read the property ‘insertBefore’, so we can assume that an insert before is indeed occuring.

Just like the first error, the problem is that we are trying to do something with an item/object/node that no longer exists. In this case, we get the first two errors as the game tries to construct some list of items to draw to the screen. It’s doing something that requires it to know the property insertBefore of that deleted node and thus fails. The traceback lets us know that this something has to do with rearranging (_rearrange) something (presumably the crafting queue), while dragging the mouse (_mouseDrag), which is handled by generic code for moving the mouse(_mouseMove) and so on down the line.

I really can’t guess why it throws out that same error twice other than to state the obvious: It needs to find the same information twice. Based on the tracebacks, it probably attempts to get that information in two different lines of the same piece of code, but that’s all we can see.

I hope that makes my guesswork somewhat more clear than mud and again, it is just guesswork. Whoever squishes this bug will be more than capable of figuring out the truth for themselves, because they’ll have actual code to look at.

3 Likes

I did understand what the error was but that really helped me understand it more
Thanks! :smile:

I can confirm this error, it generally appears for me if the crafter is just finishing up an item and they pick it up while I’m dragging another item to make it first in queue

Summary: While trying to remove a task from a work queue (click-dragging task tab down to trash tab), several errors messages appeared and the attempt to remove the task in question was stopped and the task tab returned to its place in the crafting queue. Upon trying again, the task was successfully deleted and no additional error messages appeared.
Frequency: Highly infrequent. In the space of 5 hours of gameplay, this error only occurred once.
Impact: It seemed to have no additional impact on workers or the other tasks within the crafting queue.
Attachment: The top-most error box

| The second error box (this box appeared three times consecutively)

| The final error box

Version: I’m running Alpha 10.5, release-375 (x64). I have no mods or third party content of any kind installed.
System Info: Windows 7 64bit. AMD Phenom II X6 1100T. 12Gig memory. NVIDIA GeForce GTX 680.

This sounds the same as the problem I have had. You’ll only get the errors if you are trying to move a queue item when your crafter finishes an item.

1 Like

I think this has been fixed in the latest unstable on steam as I used to get this before r375 but not had it recently

I’m still getting it on r375 if I try for it. Less of the “insertBefore” type and often only when I release the mouse button, not when the crafter finishes a job, but it’s still there.

In my case, my crafter (carpenter) hadn’t begun any of the items in his work queue despite having all the required materials for them ready and waiting in the stockpile, which was why I was removing tasks in hopes that it would jump start him to focus on the jobs I needed to do rather than assisting in mining the way he had been.

Unfortunately, I am running the game on r375.

Well, that’s good additional information at least. Might help the devs figure things out a bit better.

So, i see you guys have pinpointed the error, and i thank you for that, because being as small as the developer team is i think they appreciate the help from all of you guys, but has anybody find a fix for this? i have r519 and it stills happens

Hey there @Lorflord007, welcome to the Discourse! Thanks for the confirmation that this is still occurring! Going to ping @yshan to see if this is on the list for A15 fixes…

and I get this… Lol

release-465 (x64)
Uncaught TypeError: Cannot read property 'appendChild' of undefined
TypeError: Cannot read property 'appendChild' of undefined
    at $.widget._createHelper (http://radiant/stonehearth/ui/root/js/libs/jquery-ui-1.10.3.js:4887:79)
    at null._createHelper (http://radiant/stonehearth/ui/root/js/libs/jquery-ui-1.10.3.js:401:25)
    at $.widget._mouseStart (http://radiant/stonehearth/ui/root/js/libs/jquery-ui-1.10.3.js:4142:22)
    at null._mouseStart (http://radiant/stonehearth/ui/root/js/libs/jquery-ui-1.10.3.js:401:25)
    at $.widget._mouseMove (http://radiant/stonehearth/ui/root/js/libs/jquery-ui-1.10.3.js:938:11)
    at null._mouseMove (http://radiant/stonehearth/ui/root/js/libs/jquery-ui-1.10.3.js:401:25)
    at HTMLDocument._mouseMoveDelegate (http://radiant/stonehearth/ui/root/js/libs/jquery-ui-1.10.3.js:910:16)
    at HTMLDocument.jQuery.event.dispatch (http://radiant/stonehearth/ui/root/js/libs/jquery-1.10.2.js:5095:9)
    at HTMLDocument.elemData.handle (http://radiant/stonehearth/ui/root/js/libs/jquery-1.10.2.js:4766:46)

I’m not exactly sure what happened, was moving things around in the carpenters table because I needed to make them sooner, and this is what happened.

Hey @Minerexstacy, this looks like a UI error, is that the case? If so, were you able to press F5 to reset the UI, and did that work. If F5 did not work, or it was not a UI error, please let us know that instead.

1 Like

It was a UI error. and I didn’t even think to press F5 at the time, it ended up crafting after it made sure everything prior was in stock, just wouldn’t let me move it

Good to know. Going to page @yshan as she does a lot of the UI development. Thanks for getting back so fast!

Repaging @yshan and @sdee, has this been addressed?