Commit Graph

182 Commits

Author SHA1 Message Date
Thiago Marcos P. Santos
d80d2d5eee Remove request coalescing
Each NodeMap has its own NodeFileSource so we should not get multiple
requests of for the same resource anymore, making the coalescing
code path useless.

We still need to keep a list of pending requests indexed by Resources
for the same reason it was introduced before: Resources don't hold
a reference to a uv_loop_t, so it is fine to keep it around, unlike
mbgl::Requests. Otherwise it would cause deadlocks.

The mutex was also kept because the NodeFileSource is accessed by
some arbitrary thread created by mbgl::Map and also by the main
thread coming from the JavaScript engine. More precisely,
NodeFileSource::notify() is called from the main thread while
NodeFileSource::request() and NodeFileSource::cancel() are not,
but they all access the same data structure.
2015-08-14 20:08:07 +03:00
Mike Morris
0097710d0a Merge pull request #143 from mapbox/internal-filesource
accept FileSource options object
2015-08-05 12:00:43 -04:00
Mike Morris
d3104756af make 'cancel' function in FileSource optional
update README
2015-08-04 15:37:49 -04:00
Mike Morris
84a1e6d1c3 remove request coalescing tests 2015-08-04 15:06:36 -04:00
Mike Morris
99ba07deb3 accept options object argument to new mbgl.Map()
instead of requiring inheritence, drops mbgl.FileSource

pass NodeFileSource* around as v8::External
2015-08-04 15:06:25 -04:00
Mike Morris
396fcc8b8c 1.1.3 [publish binary] 2015-06-25 14:00:09 -04:00
Mike Morris
f550a11ff5 update changelog 2015-06-25 13:59:43 -04:00
Mike Morris
716f97f40c Merge pull request #140 from mapbox/remove_environment
Remove mbgl::Environment from logging
2015-06-25 13:58:01 -04:00
Thiago Marcos P. Santos
d41d2c63dd Remove mbgl::Environment from logging
mbgl::Environment was dropped and since most of the errors are being
forwarded to the NodeMap render callback, we can handle them there
and pinpoint exactly what NodeMap object is failing.
2015-06-25 18:23:28 +03:00
Thiago Marcos P. Santos
b99831198e Bump Mapbox GL Native to v0.4.0+
Removed mbgl::Environment.
2015-06-25 18:22:47 +03:00
Mike Morris
a107680bc9 Update CHANGELOG.md 2015-06-22 13:35:15 -04:00
Mike Morris
22c2076c5e 1.1.2 [publish binary] 2015-06-22 12:06:33 -04:00
Mike Morris
e2db5c46b5 update changelog 2015-06-22 12:06:00 -04:00
Mike Morris
2fce35b0a1 Merge pull request #134 from mapbox/134-crash_without_style
segfault instead of JS error requiring style to be set
2015-06-22 11:58:58 -04:00
Thiago Marcos P. Santos
e6c442bf4e Adjusts tests for the new API
Unskip tests that should be passing now and adjust error
messages to reflect recent changes.
2015-06-22 08:49:53 +03:00
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
d37e22b9c2 Bump Mapbox GL Native to v0.4.0
Pull the fixes for the "rendering without setting a style" crash.
2015-06-22 07:59:09 +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
Mike Morris
27fc2f18e3 clarify C++14 runtime support and external dependencies to build from source 2015-06-17 14:23:29 -04:00
Mike Morris
6d17467dbc Update CHANGELOG.md 2015-06-17 12:15:50 -04:00
Mike Morris
6081f15237 v1.1.1 [publish binary] 2015-06-16 15:37:02 -04:00
Mike Morris
7315212cb8 Merge pull request #136 from mapbox/mbgl-v0.3.5
bump mbgl to v0.3.5
2015-06-16 15:35:19 -04:00
Mike Morris
a25fa2e076 bump mbgl to v0.3.5
add geojsonvt dependency in Makefile

update changelog
2015-06-16 14:21:27 -04:00
Mike Morris
254a437051 Merge pull request #135 from mapbox/travis-publish
fix clang CXX matching
2015-06-16 13:35:57 -04:00
Mike Morris
7be5f15e50 fix clang CXX matching [publish binary]
explicitly set CXX on OS X
2015-06-16 12:54:00 -04:00
Mike Morris
b8c45b6273 match all clang++ versions [publish binary] 2015-06-15 17:56:22 -04:00
Mike Morris
6f4e727654 add npm badge [skip ci] 2015-06-15 17:15:58 -04:00
Mike Morris
5c8107ee3b v1.1.0 [publish binary] 2015-06-15 17:04:53 -04:00
Mike Morris
a29c7c34dc Merge pull request #130 from mapbox/changelog
update changelog and readme
2015-06-15 16:57:47 -04:00
Mike Morris
73abfc3d08 update changelog and readme [skip ci]
- Document Node.js v0.12.x and io.js support
- Document map.release functionality.
- Add notes on garbage collection and request handling.
- Update binary platforms and build instructions.
- Document API token FileSource implementation from
  https://github.com/mapbox/mapbox-gl-native/pull/1607
- Update Kind enum values.
2015-06-15 16:53:40 -04:00
Mike Morris
e2c56742a8 Merge pull request #129 from mapbox/129-pending_requests_hanging
Map destruction hanging with pending requests
2015-06-15 16:47:53 -04:00
Mike Morris
e06bf232f4 request coalescing fixes #114 2015-06-15 14:52:35 -04:00
Thiago Marcos P. Santos
a6ea979ec5 Add test case for the request coalescing 2015-06-15 13:54:20 +03:00
Thiago Marcos P. Santos
0d2543675f Update the tests
Reflect the changes on the previous MBGL version bump and
unskip tests that should pass now.
2015-06-15 13:54:20 +03: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
d515f8d77d Bump Mapbox GL Native to v0.3.3 2015-06-12 13:51:52 +03:00
Thiago Marcos P. Santos
e07ecfaa5f Merge pull request #133 from mapbox/remove_unused
Removed unused method on NodeFileSource
2015-06-09 11:04:04 +03:00
Thiago Marcos P. Santos
b4f21b73d0 Removed unused method on NodeFileSource 2015-06-08 15:40:45 +03:00
Mike Morris
efb583186f Merge pull request #127 from mapbox/collect-garbage
Collect garbage
2015-05-28 14:30:33 -04:00
Mike Morris
691ccff978 fix unhandled gzip test
Refs https://github.com/mapbox/mapbox-gl-native/pull/1632
2015-05-28 13:35:00 -04:00
Mike Morris
ed648f9eff skip failed request test 2015-05-28 13:35:00 -04: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
e4536789eb Merge pull request #128 from mapbox/mapbox-protocol
drop SetAccessToken from NodeMap
2015-05-27 19:09:38 -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
3e9feb7cec Merge pull request #125 from mapbox/failed-requests
Handle failed requests
2015-05-22 11:17:28 -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