Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix sporadical "cannot read property _values of undefined" error #7615

Closed
wants to merge 1 commit into from

Conversation

mourner
Copy link
Member

@mourner mourner commented Nov 22, 2018

Closes #7523. I'm not able to trace the exact race condition that causes the error, but it should be fixed with this change. Also slightly improves typing, which would catch the potential error if we didn't use the (obj: any).property hack there.

Launch Checklist

  • briefly describe the changes in this PR
  • write tests for all new functionality
  • document any changes to public APIs
  • post benchmark scores
  • manually test the debug page

for (const property in (this: any).paint._values) {
const value = (this: any).paint.get(property);
if (!this.paint)
return false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is paint (or layout) optional for this StyleLayer?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because it's calculated on recalculate, not in constructor. Alternatively, we can try setting it to empty objects there, but I think the PR solution is fine.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, I think we should investigate this further rather than covering up the symptoms. Returning false from isStateDependendent sounds wrong (since it's in an undefined state). Instead, we should not call isStateDependent when recalculate has never been called, or ensure that it is called in the constructor.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could investigate this further if there was a consistently reproducible test case, but since the issue is a rare race condition we only know of from production stack trace logs, I'd personally be fine with fixing the symptoms.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should not call isStateDependent when recalculate has never been called, or ensure that it is called in the constructor.

I wasn't able to reproduce this error condition even after a bunch of experimentation. In 36270d I took the approach of moving the paint property evaluation to the worker. This should have the additional benefit of not needing to parse the expressions on the main thread.

@anshumanbora
Copy link

I'm currently facing a similar issue. Would love to get an update about the pending PR.

@mourner
Copy link
Member Author

mourner commented Jan 15, 2019

@asheemmamoowala let's resurrect that fix-7523 branch into a PR maybe?

@asheemmamoowala
Copy link
Contributor

@mourner - its up #7790.

@mourner mourner closed this Jan 21, 2019
@mourner mourner deleted the fix-values-error branch August 1, 2019 11:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

JS errors while zooming (Cannot read property '_values' of undefined)
4 participants