CartoDB / torque

Temporal mapping for CARTO
http://cartodb.github.com/torque/
BSD 4-Clause "Original" or "Old" License
397 stars 131 forks source link

TypeError: Cannot read property '_tiles' of undefined #306

Closed Algunenano closed 5 years ago

Algunenano commented 5 years ago
[2019-05-29 09:12:14.886] [FATAL] [default] - TypeError: Cannot read property '_tiles' of undefined
    at PointRenderer.setCartoCSS (/home/ubuntu/www/node-windshaft/releases/20190521103931/node_modules/torque.js/lib/torque/renderer/point.js:122:57)
    at new PointRenderer (/home/ubuntu/www/node-windshaft/releases/20190521103931/node_modules/torque.js/lib/torque/renderer/point.js:77:10)
    at /home/ubuntu/www/node-windshaft/releases/20190521103931/node_modules/windshaft/lib/windshaft/renderers/torque/png_renderer.js:90:29
    at /home/ubuntu/www/node-windshaft/releases/20190521103931/node_modules/windshaft/lib/windshaft/renderers/torque/renderer.js:173:17
    at ctor.PSQLAdaptor.ctor._handleResult (/home/ubuntu/www/node-windshaft/releases/20190521103931/node_modules/windshaft/lib/windshaft/renderers/torque/psq
l_adaptor.js:16:9)
    at Result.<anonymous> (/home/ubuntu/www/node-windshaft/releases/20190521103931/node_modules/cartodb-psql/lib/psql.js:325:24)
    at Result.Query.handleReadyForQuery (/home/ubuntu/www/node-windshaft/releases/20190521103931/node_modules/pg/lib/query.js:144:10)
    at Connection.<anonymous> (/home/ubuntu/www/node-windshaft/releases/20190521103931/node_modules/pg/lib/client.js:184:19)
    at Connection.emit (events.js:189:13)
    at Socket.<anonymous> (/home/ubuntu/www/node-windshaft/releases/20190521103931/node_modules/pg/lib/connection.js:135:12)
TypeError: Cannot read property '_tiles' of undefined
    at PointRenderer.setCartoCSS (/home/ubuntu/www/node-windshaft/releases/20190521103931/node_modules/torque.js/lib/torque/renderer/point.js:122:57)
    at new PointRenderer (/home/ubuntu/www/node-windshaft/releases/20190521103931/node_modules/torque.js/lib/torque/renderer/point.js:77:10)
    at /home/ubuntu/www/node-windshaft/releases/20190521103931/node_modules/windshaft/lib/windshaft/renderers/torque/png_renderer.js:90:29
    at /home/ubuntu/www/node-windshaft/releases/20190521103931/node_modules/windshaft/lib/windshaft/renderers/torque/renderer.js:173:17
    at ctor.PSQLAdaptor.ctor._handleResult (/home/ubuntu/www/node-windshaft/releases/20190521103931/node_modules/windshaft/lib/windshaft/renderers/torque/psql_adaptor.js:16:9)
    at Result.<anonymous> (/home/ubuntu/www/node-windshaft/releases/20190521103931/node_modules/cartodb-psql/lib/psql.js:325:24)
    at Result.Query.handleReadyForQuery (/home/ubuntu/www/node-windshaft/releases/20190521103931/node_modules/pg/lib/query.js:144:10)
    at Connection.<anonymous> (/home/ubuntu/www/node-windshaft/releases/20190521103931/node_modules/pg/lib/client.js:184:19)
    at Connection.emit (events.js:189:13)
    at Socket.<anonymous> (/home/ubuntu/www/node-windshaft/releases/20190521103931/node_modules/pg/lib/connection.js:135:12)
[2019-05-29 09:12:14.887] [INFO] [default] - Process is going to exit with code: 1

As with https://github.com/CartoDB/turbo-carto/issues/83, it's crashing in production.

cc/ @CartoDB/rt-managers

Algunenano commented 5 years ago

3 4 5 instances of this error so far today.

jgoizueta commented 5 years ago

It seems that undefined layer in a torque renderer has caused problems before and has been handled by coping with undefined layers. I'm not sure that's the best option, but I'm not sure either if it's worth investigating the cause of the undefined layer.

rafatower commented 5 years ago

I managed to reproduce the issue with a point dataset and the following cartocss:

Map {
  -torque-frame-count: 1;
  -torque-animation-duration: 30;
  -torque-time-attribute: "cartodb_id";
  -torque-aggregation-function: "count(1)";
  -torque-resolution: 4;
  -torque-data-aggregation: linear;
}
#layer {
  marker-width: 16.6;
  /*marker-width: ramp([value], range(2, 40), jenks(6));*/
  marker-fill-opacity: 1;
  marker-file: url(http://cartodb-libs.global.ssl.fastly.net/cartodbui/assets/unversioned/images/alphamarker.png);
  marker-allow-overlap: true;
  marker-line-width: 1;
  marker-line-color: #FFFFFF;
  marker-line-opacity: 1;
  marker-comp-op: darken;
  image-filters: colorize-alpha(#4b2991,#872ca2,#c0369d,#ea4f88,#fa7876,#f6a97a,#edd9a3);
}

and then trying to Export image... from Builder.

That said, there are a few dark corners in this very specific use case:

https://github.com/CartoDB/Windshaft/blob/a9b3b6492c4e01b16b12c807bf10f6d5d2661d32/lib/windshaft/renderers/torque/png_renderer.js#L90

in the stack trace). Usually that works by "compiling" turbo-carto to plain cartocss and then handing it over to the tiler, but the commented out code messes it up as it believes it has a turbo-carto, here:

https://github.com/CartoDB/torque/blob/4d2540ef98018775cfcd8fee8df2c39c6fc13230/lib/torque/renderer/point.js#L121

and that does NOT happen when that code is uncommented.

So, I suspect the crash is triggered by some legacy "dead code" that is only reachable in this faulty condition: commented code that resembles turbo-carto.

rafatower commented 5 years ago

There must be some bad interaction with Windshaft, cause it should have a layer defined anyway.

rafatower commented 5 years ago

After much tinkering with Windshaft, adding traces to callbacks and so forth, I decided to go for the "safe preventive" approach: get rid of comments and do not attempt to read layers nor apply turbocarto if there's no layer definition: https://github.com/CartoDB/torque/pull/307

simon-contreras-deel commented 5 years ago

:rocket: