Gamua / Starling-Framework

The Cross Platform Game Engine
http://www.starling-framework.org
Other
2.85k stars 819 forks source link

Starling 2.0: Images with cached filters are not surviving lost context #863

Closed serjek closed 6 years ago

serjek commented 8 years ago

Here is the self-explaining code:

var img:Image = new Image(StarlingData.assets.getTexture("graph_blue"));
img.width = 200;
img.height = 200;
this.addChild(img);

const f:DropShadowFilter=new DropShadowFilter(1,Math.PI/2,0,.4,4);
img.filter = f;
f.cache();
Starling.juggler.delayCall(Starling.context.dispose,2);

Once context is lost and restored after 2 seconds image is gone. It will remain in place if filter is not cached though, but I think filters should handle context lost/restore by themselves, just like ConcreteTexture does.

Note: quad seem to be working fine under same conditions.

PrimaryFeather commented 8 years ago

Yes, I'm aware of that issue — nevertheless, thanks for reporting it! The problem that I need to solve is that a texture doesn't know right now on which meshes it is in use. And when it's restored after a context loss, this may happen asynchronously; so it would need to notify its "user" (in this case: the image) that its needs to be redrawn (in this case: redraw the filter).

So I'll have to add such a mechanism; only then I can fix this.

BTW, you can ignore my mumbling above; it's probably more a reminder for my future self what's going on here. :wink:

serjek commented 8 years ago

All right, it is not a problem to trigger filter.cache() manually on context restore (or several frames after to ensure correct call order). Just thought you'll need this issue properly logged.

PrimaryFeather commented 7 years ago

Just for reference: I just noticed this is actually the same as #474. (No, there is not a fix yet, unfortunately.)

PrimaryFeather commented 6 years ago

(Being a duplicate, I'm closing this issue.)