Commit Graph

41 Commits

Author SHA1 Message Date
Thiago Marcos P. Santos
1ae7dd585d Throw when style is not loaded
mbgl::Map won't throw if the style is not set but we
can track that on NodeMap.
2015-06-22 08:48:44 +03:00
Thiago Marcos P. Santos
d434746a46 Better error messages
Use the error message passed by the error exception instead of
always reporting "Error rendering image".
2015-06-19 16:52:03 -04:00
Thiago Marcos P. Santos
b602835626 Fix invalid NodeRequest reference
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.
2015-06-15 13:54:20 +03:00
Thiago Marcos P. Santos
34ef7ac003 Implement request coalescing and synchronous request cancellation
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.
2015-06-15 01:52:15 +03:00
Thiago Marcos P. Santos
b4f21b73d0 Removed unused method on NodeFileSource 2015-06-08 15:40:45 +03:00
Mike Morris
9214584efb drop extraneous NodeFileSource v8::Persistent
Remove from NodeRequest to stop preventing garbage collection.
2015-05-28 13:35:00 -04:00
Mike Morris
fe3d6bbbd5 expose map.release() method 2015-05-28 13:35:00 -04:00
Mike Morris
cb47f902e1 #include <memory> in node_file_source.hpp 2015-05-27 18:40:53 -04:00
Mike Morris
44490f620c drop SetAccessToken from NodeMap
Handle this is JavaScript where necessary.
2015-05-27 18:24:43 -04:00
Mike Morris
2e73682de0 std::make_unique 2015-05-27 16:54:09 -04:00
Mike Morris
16ec628d8e return an error if map.renderStill returns a std::exception_ptr
store exception_ptr on NodeMap

add test for map.render returning an error
2015-05-22 11:09:50 -04:00
Mike Morris
830a9b3972 drop CompressPNG 2015-05-15 13:24:04 -04:00
Mike Morris
b7ab9485d4 upgrade node modules, switch from tap-spec to faucet 2015-05-14 13:53:05 -04:00
Mike Morris
11b214fed6 if/else on NODE_MODULE_VERSION instead of UV_VERSION 2015-05-14 12:55:54 -04:00
Mike Morris
c0fe624ecd add node v0.12 and io.js compatibility 2015-05-14 12:55:54 -04:00
Mike Morris
1b9f98440a ignore GCC diagnostics for node.h 2015-05-13 12:58:34 -04:00
Mike Morris
1eeb7b65e9 update travis script for https://github.com/mapbox/mapbox-gl-native/pull/1339
refactor mbgl travis scripts

source travis_helper.sh, run setup.sh

pushd/popd

sudo false

travis matrix with c++14 support?

drop setup_mesa.sh

update binding.gyp

language: c

drop thread_object, add async_queue

fix async_queue.hpp includes

std::make_unique

pip install awscli
2015-05-13 12:58:04 -04:00
Mike Morris
3eb8ec9ca6 map.resize, close server after tests, not inside 2015-05-05 13:44:52 -04:00
Mike Morris
840e22bf90 adapt to changes from
https://github.com/mapbox/mapbox-gl-native/pull/1065
2015-05-05 13:43:43 -04:00
Mike Morris
ca897ce407 bump mbgl
drop mbgl::Environment from NodeFileSource
switch to mbgl::Map::Mode::Still
2015-04-29 15:26:29 -04:00
Konstantin Käfer
f2c9e9fb67 add xcode project target
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.
2015-04-17 16:02:29 +02:00
Mike Morris
417741b13f adapt to still image render mode changes
https://github.com/mapbox/mapbox-gl-native/pull/1272

Some tests are hanging with no errors or log messages
when map.load is passed a style but never rendered.
2015-04-17 16:01:54 +02:00
Mike Morris
a11a92f9a4 add LogMessage constructors for default values 2015-04-17 15:57:31 +02:00
Mike Morris
8e790ca322 log environment ID and threadName if in scope 2015-04-17 15:57:31 +02:00
Mike Morris
8671015119 move node log from backend to observer pattern
back to gl-native master branch
2015-04-17 15:57:22 +02:00
Mike Morris
ca0da9626e NanAssignPersistent source in NodeMap constructor, fixes #109 2015-04-03 15:43:40 -04:00
Mike Morris
d9c446a075 init display connection on module load
add sudo: required

move source up to initialization on NodeMap

static sharedDisplay method
2015-04-02 17:21:16 -04:00
Mike Morris
9a297051c7 adapt NodeFileSource around mbgl::Environment additions 2015-03-19 17:45:15 -04:00
Mike Morris
82317df050 move back to node-mapbox-gl-native 2015-02-24 12:16:21 -05:00
Mike Morris
030c88ce10 oops, fix lat, lng order 2015-02-18 16:41:11 -05:00
Mike Morris
10334522ad fix setLatLngZooom 2015-02-18 16:22:26 -05:00
Konstantin Käfer
b1deba8d95 do not .release() in function call; execution order is undefined 2015-02-13 15:09:32 -08:00
Konstantin Käfer
464ecaf7c7 make sure the log notifications don't keep the threadloop alive 2015-02-12 18:45:44 -08:00
Konstantin Käfer
81c45ab39a no need to use a pointer to a unique_ptr when we can just use the pointer 2015-02-12 18:18:43 -08:00
Konstantin Käfer
caae73a33a expose log messages to node.js 2015-02-12 13:04:06 -08:00
Konstantin Käfer
8c6f71fdb2 adapt to static-render branch changes [skip ci]
still missing updated tests
2015-02-11 19:35:39 -08:00
Mike Morris
df396d7d89 get tests passing on travis
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
2015-02-10 15:24:02 -08:00
Konstantin Käfer
fc4df7992f this has been implemented 2015-02-06 10:51:16 +01:00
Konstantin Käfer
339ebca759 allow more arguments, but require at least one 2015-02-06 10:46:49 +01:00
Konstantin Käfer
66ca191ab2 add first render test 2015-02-04 20:09:02 +01:00
Konstantin Käfer
07867edd47 initial version with updated build system 2015-02-04 18:21:39 +01:00