Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

Notify renderStill() of request failures - #1588

Merged
tmpsantos merged 7 commits into
masterfrom
1565-failed_requests
May 22, 2015
Merged

tmpsantos merged 7 commits into
masterfrom
1565-failed_requests

Conversation

@tmpsantos

Copy link
Copy Markdown
Contributor

Propagates the failure all the way from the object making the requests to the failureCallback that has to be passed to renderStill() in addition to the usual successCallback.

The branch also adds unit tests simulating request failures on all resources we request.

Fixes #1565.

@tmpsantos tmpsantos self-assigned this May 18, 2015
@jfirebaugh

Copy link
Copy Markdown
Contributor

Definitely agree with the approach here. I started on something similar in 667dc1f, except I was going to change the signature of the existing callback to accept a std::exception_ptr as the first argument. In non-error cases it would be null. This would be a node-like callback convention, and I think I prefer it -- one less argument to thread through the code, and passing an error object of some sort will be more informative than a boolean "succeeded / failed" status.

@tmpsantos
tmpsantos force-pushed the 1565-failed_requests branch 2 times, most recently from 73f1310 to 91c07d0 Compare May 20, 2015 07:19
@mikemorris

Copy link
Copy Markdown
Contributor

Alright, had a chance to test this out and while it does target the hanging tests seen in cutting-room-floor/tilelive-gl#25, I'm not sure if the solution is ideal.

  • If a render call requests multiple vector tiles and a single request fails, no image is returned. The render call would previously still return an image if some tile requests failed. In the case of the 1-0-1 test case, the three spurious tile requests are for subpixel border tiles that are not visible on the resulting image. I'm not sure what the desired behavior here should be
# 1-0-1
ok 19 null
{ class: 'HttpRequest',
  severity: 'ERROR',
  text: '[./fixtures/tiles/1-1-1.vector.pbf] tile loading failed: Error: ENOENT, open \'/Users/mikemorris/gyp/tilelive-gl/test/fixtures/tiles/1-1-1.vector.pbf\'',
  environment: 7,
  threadName: 'Map' }
{ class: 'HttpRequest',
  severity: 'ERROR',
  text: '[./fixtures/tiles/1-1-0.vector.pbf] tile loading failed: Error: ENOENT, open \'/Users/mikemorris/gyp/tilelive-gl/test/fixtures/tiles/1-1-0.vector.pbf\'',
  environment: 7,
  threadName: 'Map' }
not ok 20 Error: Didn't get an image

@tmpsantos

Copy link
Copy Markdown
Contributor Author

@jfirebaugh @mikemorris thanks for the feedback. I rewrote the patch using std::exception_ptr and it indeed is looking much better. It also made the unit tests better as a side effect.

@mikemorris

Copy link
Copy Markdown
Contributor

👍 to merge this

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should we use the single callback convention here too?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Should we use the single callback convention here too?

Yes, I will refactor this one in another branch. I've to find a nice way of replacing this one because the Worker expects a std::function<void()> as callback and I want to report errors during the tile parsing.

@jfirebaugh

Copy link
Copy Markdown
Contributor

👍

tmpsantos added 7 commits May 22, 2015 10:44
The callback will be called when any of the resources requested
from the network failed to load.

There is not recovery implemented yet, so the closest thing to
reseting the Map object and reloading all the resources would
be setting a new style.
- MockFileSource
  Will load pre-defined resources from the filesystem. It supports
  passing a string, that when it matches an URL, will simulate a failure.

- MockView
  It is just a no-op to not get in the way when testing
  resource loading.

Few more additions:

- style.json
  Specially crafted style that will look always for the same tile,
  glyph range, etc at the "test/fixtures/resources/" path. No matter
  where you look (or at what zoom), you always get the same stuff.

- vector.pbf
  This taken from a part of Taipei that will request several glyph
  ranges.
This first test will simulate a request failure on every resource
directly or indirectly loaded by the ResourceLoader. The idea is
to verify whenever we are failing gracefully or not.
@tmpsantos
tmpsantos force-pushed the 1565-failed_requests branch from 0e85f49 to 6624dbb Compare May 22, 2015 07:44
tmpsantos added a commit that referenced this pull request May 22, 2015
Notify renderStill() of request failures
@tmpsantos
tmpsantos merged commit 8678d50 into master May 22, 2015
@mourner mourner removed the ready label May 22, 2015
@tmpsantos
tmpsantos deleted the 1565-failed_requests branch May 22, 2015 07:55
@mikemorris

Copy link
Copy Markdown
Contributor

Testing changes for https://github.com/mapbox/node-mapbox-gl-native/issues/122, I noticed that when a std::exception is returned with a map.renderStill call, the cancel method on the FileSource implementation may not get called. I suspect this could be preventing a std::unique_ptr::reset call from completing, as the underlying mbgl::Map object may still be in use (this is pure conjecture and may not actually be how C++ works but something it preventing code from continuing to run at this point).

Replicated this with Node.js v0.12.0 on commit https://github.com/mapbox/node-mapbox-gl-native/commit/8d35b678ede00e51b12dd3fed95d92eed7b08ba6 by running node test/js/map.test.js

@mikemorris

Copy link
Copy Markdown
Contributor

^ Scratch that, rebuilt and not replicating this any more...

Welp, replicating this on Travis now... https://travis-ci.org/mapbox/node-mapbox-gl-native/builds/64294991

This hang seems to happen inconsistently, sometimes it exits cleanly...

First time I saw this failure was with https://github.com/mapbox/node-mapbox-gl-native/commit/a4f90b2d388fd6359a09bde9d9d6c91e834f3816

@tmpsantos

Copy link
Copy Markdown
Contributor Author

Testing changes for mapbox/node-mapbox-gl-native#122, I noticed that when a std::exception is returned with a map.renderStill call, the cancel method on the FileSource implementation may not get called. I suspect this could be preventing a std::unique_ptr::reset call from completing, as the underlying mbgl::Map object may still be in use (this is pure conjecture and may not actually be how C++ works but something it preventing code from continuing to run at this point).

That is correct. I managed to isolate the problem in a unit test and I'm cooking a fix for this. I don't think we should call cancel() on the FileSource on failure, but we should cancel all pending requests of a Map object at its dtor. The Map object in theory could be destroyed at any moment and despite the fact that we join all the threads and etc before cleaning the object, it should be done quickly (and it is not the case now, it seems).

I will elaborate the problem better in a new issue and will cc you.

@mikemorris thanks for reporting!

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MapMode::Still will never complete if requests fail

4 participants