bp74 / StageXL

A fast and universal 2D rendering engine for HTML5 and Dart.
http://www.stagexl.org
Other
881 stars 82 forks source link

Error with mask and filters #278

Closed nilsdoehring closed 7 years ago

nilsdoehring commented 7 years ago

Hi Bernhard,

I've noticed an error introduced between 1.1.0+1 and 1.2.0 that occurs when a filter is used on an object that has a mask applied inside one of its children. RenderMode is WebGL.

Code for reproducing the error:

  Sprite p = new Sprite();
  stage.addChild(p);

  Sprite c = new Sprite();
  c.graphics
    ..rect(0, 0, 200, 100)
    ..fillColor(Color.Red);
  c.mask = new Mask.circle(100, 50, 50);
  c.addTo(p);

  p.filters = [new ColorMatrixFilter.grayscale()];

If the mask and filter are on the same 'hierarchy', then no error is thrown and everything renders fine. It doesn't matter which kind of filter or mask is used.

Stacktrace (happens in each frame):

Uncaught Unhandled exception:
RangeError (index): Invalid value: Valid value range is empty: -1
#0      List.[] (dart:core-patch/growable_array.dart:153)
#1      List.removeLast (dart:core-patch/growable_array.dart:216)
#2      RenderContextWebGL.endRenderMask (package:stagexl/src/engine/render_context_webgl.dart:159:38
...

Thanks!

bp74 commented 7 years ago

Thanks for the bug report and the repro case. There were some changes and optimizations for masks, so probably something went wrong. i will fix it over the weekend!

bp74 commented 7 years ago

This issue is fixed in 8bc2d57c1d1776d700af63ba801fc9769d8c203d

I'm still working on another issue. Once this other issue is resolved too i will probably an updated version for StageXL 1.2. I will keep you posted.

bp74 commented 7 years ago

Fix released with StageXL 1.2.0+3