Skip to content

Flash when switching from a DDS paint property to a constant #3949

Closed

Description

@stevage

mapbox-gl-js version: 0.28.0 and 0.30.0

Steps to Trigger Behavior

  1. https://city-of-melbourne.github.io/anything-map/#84bf-dihi
  2. Hover over a point, then click 'VENUE_RECN'
  3. Click the Close X button

Expected Behavior

  1. Circles the same size
  2. Circles vary in size
  3. Circles the same size

Actual Behavior

In step 3:

Uncaught TypeError: this.functionInterpolationT is not a function
    at StyleDeclaration.calculateInterpolationT (style_declaration.js:58)
    at t.i.getPaintInterpolationT (style_layer.js:162)
    at ProgramConfiguration.setUniforms (program_configuration.js:193)
    at Object.drawCircles [as circle] (draw_circle.js:30)
    at Painter.renderLayer (painter.js:271)
    at Painter.renderPass (painter.js:254)
    at Painter.render (painter.js:213)
    at e._render (map.js:1128)

Sorry, this is far from a minimal repro case, but what is happening: after initially creating the style, in step 2 I call map.setPaintProperty('points','circle-radius', p) where p is:

{
  "property": "VENUE_RECN",
  "stops": [
    [
      {
        "zoom": 10,
        "value": 5
      },
      1
    ],
    [
      {
        "zoom": 10,
        "value": 1627
      },
      3
    ],
    [
      {
        "zoom": 17,
        "value": 5
      },
      3
    ],
    [
      {
        "zoom": 17,
        "value": 1627
      },
      10
    ]
  ]
}

In step 3, I call it with this parameter:

{
  "stops": [
    [
      10,
      2
    ],
    [
      17,
      5
    ]
  ]
}

Before I go too far creating a minimal repro case, just wanted to check it wasn't already known.

Activity

  1. lucaswoj commented on Jan 11, 2017

    @lucaswoj
    Contributor

    Thanks for the bug report! These symptoms don't look familiar to me.

  2. jfirebaugh commented on Feb 9, 2017

    @jfirebaugh
    Contributor

    @stevage I don't see a "Close X" button on the page after following those steps. Would you mind creating a minimal demo?

  3. stevage commented on Feb 10, 2017

    @stevage
    ContributorAuthor

    Sorry, I removed the close button in that case because of this bug :) Will create a minimal repro.

  4. jfirebaugh commented on Mar 23, 2017

    @jfirebaugh
    Contributor

    Closing here for now; feel free to reopen if this continues to be an issue and you have a chance to create a minimal repro.

  5. aparlato commented on Apr 18, 2017

    @aparlato

    Created a minimal demo of this bug in the circle-color property:
    https://jsbin.com/bazutat/edit?html,js,console,output

    Demo starts off with circle-color being a DDS zoom and property function.

    Using map.setPaintProperty(), both setting it from this to a DDS function that is property only or to a literal value breaks the map and gives us this error:

    style_declaration.js:70 Uncaught TypeError: this._functionInterpolationT is not a function
        at StyleDeclaration.calculateInterpolationT (style_declaration.js:70)
        at CircleStyleLayer.getPaintInterpolationT (style_layer.js:172)
        at ProgramConfiguration.setUniforms (program_configuration.js:244)
        at Object.drawCircles [as circle] (draw_circle.js:30)
        at Painter.renderLayer (painter.js:288)
        at Painter.renderPass (painter.js:271)
        at Painter.render (painter.js:225)
        at Map._render (map.js:1388)
    

    Demo itself is setting it to a literal paint property.

    cc @jfirebaugh

  6. mourner commented on Apr 19, 2017

    @mourner
    Member

    @jfirebaugh this seems to happen like this:

    1. Layer paint property changes immediately.
    2. The main thread requests a corresponding layer update from a worker
    3. On the next frame, before the buffers (with program configuration) have updated on the main thread, the old program configuration tries to calculate an interpolated value but fails because layer.getPaintInterpolationT no longer works (because the layer was already updated to a different property declaration).

    Any ideas on how we should handle this race condition? I tried simply returning a 0 interpolation value if the layer is not a zoom-and-property layer. This leads to a flash of incorrect color until the tiles are updated, but is at least better than breaking the map with an error.

  7. self-assigned this
    on Apr 19, 2017
  8. mourner commented on Apr 19, 2017

    @mourner
    Member

    For a proper fix that handles all edge cases, I guess we would need to either:

    • Re-architect the style layer code so that each tile has its own style object which is constructed on the worker side and then reconstructed on the main thread. edit: although it would be weird considering methods like map.getPaintValue which would have to fetch the first rendered tile for the value.
    • Or do the previously discussed "do not update tiles on screen until they loaded for the whole view", which is a really difficult refactoring.

    Should I submit the color flash PR now, and leave difficult refactorings for later?

  9. changed the title [-]this.functionInterpolationT is not a function[/-] [+]Error when switching from a DDS paint property to a constant[/+] on Apr 19, 2017
  10. jfirebaugh commented on Apr 19, 2017

    @jfirebaugh
    Contributor

    Native handles this by:

  11. changed the title [-]Error when switching from a DDS paint property to a constant[/-] [+]Flash when switching from a DDS paint property to a constant[/+] on Apr 21, 2017
  12. mourner commented on Apr 21, 2017

    @mourner
    Member

    This no longer throws an error as of #4611, just causes a short flash of incorrect value while new buffers are loading, but keeping the issue open in case we want to address it in a way Native does, per @jfirebaugh's comment above.

  13. ChrisLoer commented on Aug 23, 2017

    @ChrisLoer
    Contributor

    I just ran into this... took a long time to debug. 😞

    In my case I was transitioning the opacity of several layers between being either a constant "0" or "1" or an intermediate value using a property function. An easy workaround was just to use a property function for all of them, but set the property function to effectively return a constant value.

  14. jfirebaugh commented on Oct 27, 2017

    @jfirebaugh
    Contributor

    → #4012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions