ID:2390593
 
Resolved
Images did not sync visual contents like they do with appearances, causing glitches in some cases. There is a server component to this issue as well.
BYOND Version:512.1445
Operating System:Windows 10 Pro
Web Browser:Chrome 68.0.3440.75
Applies to:Dream Seeker
Status: Resolved (512.1446)

This issue has been resolved.
Descriptive Problem Summary: I am currently creating and removing objects from an image's vis_contents in order to create an interface. Nevertheless, for some reason, if there are existing objects and you create new ones (I believe they need to be the same type, though I am not entirely sure about this point) this visual bug happens:

Numbered Steps to Reproduce Problem: Press the verb "Bug" a couple of times and you'll notice what I am talking about

Code Snippet (if applicable) to Reproduce Problem:
mob/verb/Bug()
var/image/I = locate("Bug")
if(I)
for(var/obj/O in I.vis_contents)
I.vis_contents -= O

else

I = image(null, src)
I.tag = "Bug"
src<<I

var {B = 10; eX; eY}
while(B)
var/obj/O = new/obj/Object {pixel_x = -120; pixel_y = 100; alpha = 150} ()
O.pixel_x += eX
O.pixel_y += eY
O.color = rgb(rand(0, 255), rand(0, 255), rand(0, 255))
I.vis_contents += O
eX += 50
if(eX == 50 *5) {eY -= 50; eX = 0}
B --

obj
Object icon = 'Icon.dmi'


Expected Results: The old objects are removed while the new objects are created with the pixel_x and pixel_y that were set on them.

Actual Results: For some reason this doesn't happen and you can see the objects with null pixel_x and pixel_y?

Does the problem occur:
Every time? Or how often? Most of the times, though not always I'd say
In other games? On every game I've tested this on yes
In other user accounts? Yes
On other computers? Yes

When does the problem NOT occur? The first time you use the verb (if there are no existing objects, of course)

Did the problem NOT occur in any earlier versions? If so, what was the last version that worked? (Visit http://www.byond.com/download/build to download old versions for testing.) It did, I tested it on both the latest version, the previous version, and 512.1442.

Workarounds: This may be caused when the object is being deleted. I've also created the object on src's contents and you wouldn't see the problem; but, of course, this issue wasn't happening as the objects weren't collected by the garbage collector, but after being set to loc = null, the same visual bug happened.

Gif: https://imgur.com/a/TlHCZqT
Gif with one single object: https://imgur.com/a/m9cOqqx
Source: https://mega.nz/#!0NBklCAI!kOrPk_CwhFh_m4yl6XU5UR0-9oNKhDB4M kmNOBgQ45M
I have just noticed that this bug happens *almost* all the time after the 3rd time you press "Bug".

https://imgur.com/a/tstSCKu
I actually don't understand what you're saying in your description of the problem. Clicking the "Bug" verb three times did nothing different than the previous two times, and continuing to click still did nothing different. Your description is sorely lacking in detail.

Can you please explain in depth what exactly is going wrong, step by step?
In response to Lummox JR
Lummox JR wrote:
I actually don't understand what you're saying in your description of the problem. Clicking the "Bug" verb three times did nothing different than the previous two times, and continuing to click still did nothing different. Your description is sorely lacking in detail.

Can you please explain in depth what exactly is going wrong, step by step?

It definitely did.
Every time the object is created it is animated from alpha 0 to 255, and you can see how after this animation has been played twice (as 2 objects were created), the next time I click the verb the result is different

/Edit/ The object that is in the image's vis_contents is displayed as if it's pixel_x and pixel_y were both set to 0 once removed from the object's vis_contents (right before being deleted by the garbage collector). If they aren't deleted after being removed from vis_contents the visual bug doesn't happen, but once you delete it (ex: setting it's loc to null) it happens again. I've tried deleting it using del() and nothing wrong happened, though.
In response to Lummox JR
https://imgur.com/a/cdjlpPE
/Edit/ Unghh... it skips some frames due to the program I used to record this gif (or perhaps imgur did this). Nevertheless, you'll see what I mean if you try the source after the 3rd time you press "Bug"

It happens really fast, but it's clearly visible.
https://imgur.com/a/HqpnuMt
Shoot, I actually posted my response to the wrong thread. The project I was looking at was the one for id:2390598. Nevertheless your clarification here was helpful for this report.
I have just noticed something really odd.

The icon that is displayed incorrectly is not the one that got removed the last time, but the one before:

https://imgur.com/a/ILZyULB

So we have dark blue, yellow, red (plus you can see the dark blue (the first object)) being displayed again on the default position
A workaround for the problem in this particular case is to set I.vis_contents = null instead of subtracting one object at a time. That's better practice anyway, as any change to an image's vis_contents will fire off a message and you're therefore sending 9 totally unnecessary messages.
Lummox JR resolved issue with message:
Images did not sync visual contents like they do with appearances, causing glitches in some cases. There is a server component to this issue as well.