On the code path built with node v0.12.4, we are storing
an invalid reference to NodeRequest on the "pending" list. It will
crash when we need to access it like we do when canceling a request.
Ideally we should just have a "std::unordered_map<mbgl::Resource,
v8::UniquePersistent>" but that is not possible because the move
semantics are not fully implemented until V8 v4.3.22. It can be used
on a std::vector but not on a std::map.
See: https://code.google.com/p/v8/issues/detail?id=3669
The solution for keep using C++11 move semantics is to declare the
v8::CopyablePersistentTraits shenanigans and explicitly clear the
v8::Persistent (like we do already for node v0.10).
When Node gets V8 v4.3.22+ we can go back to v8::UniquePersistent
with a more clear implementation.
When requests are made to the FileSource, we now group them by
resource, similarly to what is done on the native implementation. The
file source will reuse the same Response for all the requests on the
observer list.
The NodeRequest no longer holds a reference to the mbgl::Request, so
we can cancel it synchronously. This is needed to avoid a deadlock
when releasing the NodeMap resources with pending requests.
Before:
- Main thread | NodeMap::release()
- Main thread | mbgl::~Map()
- Main thread | Blocks waiting for the Map thread to join
- Map thread | mbgl::Request::cancel()
- Map thread | NodeFileSource posts the "cancel" message to main thread
- *deadlock* | Map thread cannot join because mbgl::Request holds a
reference to the Map thread main loop. Main thread is
blocked, never gets the "cancel" message.
Now:
- Main thread | NodeMap::release()
- Main thread | mbgl::~Map()
- Main thread | Blocks waiting for the Map thread to join
- Map thread | Request::cancel()
- Map thread | NodeFileSource::cancel(), destroys the mbgl::Request
synchronously, mutex guarded access. We also send
a notification to cancel the NodeRequest on the main
thread.
- Map thread | Map thread joins.
- Main thread | NodeMap::release() returns
- Main thread | NodeRequest gets canceled. If NodeRequest replies
before it gets the "cancel" message, nothing happens,
notification gets discarded.
Use locally installed node-pre-gyp if there's no global one.
This is necessary to be able to run make outside of npm.
Make example executable.
Change path to the request include file.
Bump mbgl to master.
add iam template with mapbox-gl-testing and mapbox-node-binary permissions
add travis build scripts and .travis.yml
rm -f platform gypi
map.resize is private now, called by view.resize
set stdlib and c++11 per platform, link glfw3 ldflags on linux
pass --clang to node-gyp per https://github.com/mapbox/mapbox-gl-native/pull/364#issuecomment-51735692