{"action":"created","issue":{"url":"https://api.github.com/repos/mapbox/mapbox-gl-native/issues/2400","labels_url":"https://api.github.com/repos/mapbox/mapbox-gl-native/issues/2400/labels{/name}","comments_url":"https://api.github.com/repos/mapbox/mapbox-gl-native/issues/2400/comments","events_url":"https://api.github.com/repos/mapbox/mapbox-gl-native/issues/2400/events","html_url":"https://github.com/mapbox/mapbox-gl-native/issues/2400","id":107940042,"number":2400,"title":"Fix uv_async crash (aka Option B)","user":{"login":"bleege","id":989928,"avatar_url":"https://avatars.githubusercontent.com/u/989928?v=3","gravatar_id":"","url":"https://api.github.com/users/bleege","html_url":"https://github.com/bleege","followers_url":"https://api.github.com/users/bleege/followers","following_url":"https://api.github.com/users/bleege/following{/other_user}","gists_url":"https://api.github.com/users/bleege/gists{/gist_id}","starred_url":"https://api.github.com/users/bleege/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bleege/subscriptions","organizations_url":"https://api.github.com/users/bleege/orgs","repos_url":"https://api.github.com/users/bleege/repos","events_url":"https://api.github.com/users/bleege/events{/privacy}","received_events_url":"https://api.github.com/users/bleege/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/mapbox/mapbox-gl-native/labels/Android","name":"Android","color":"5319e7"},{"url":"https://api.github.com/repos/mapbox/mapbox-gl-native/labels/crash","name":"crash","color":"ff00ff"},{"url":"https://api.github.com/repos/mapbox/mapbox-gl-native/labels/in%20progress","name":"in progress","color":"ededed"}],"state":"open","locked":false,"assignee":{"login":"ljbade","id":1215089,"avatar_url":"https://avatars.githubusercontent.com/u/1215089?v=3","gravatar_id":"","url":"https://api.github.com/users/ljbade","html_url":"https://github.com/ljbade","followers_url":"https://api.github.com/users/ljbade/followers","following_url":"https://api.github.com/users/ljbade/following{/other_user}","gists_url":"https://api.github.com/users/ljbade/gists{/gist_id}","starred_url":"https://api.github.com/users/ljbade/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ljbade/subscriptions","organizations_url":"https://api.github.com/users/ljbade/orgs","repos_url":"https://api.github.com/users/ljbade/repos","events_url":"https://api.github.com/users/ljbade/events{/privacy}","received_events_url":"https://api.github.com/users/ljbade/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/mapbox/mapbox-gl-native/milestones/20","html_url":"https://github.com/mapbox/mapbox-gl-native/milestones/android-v2.3.0","labels_url":"https://api.github.com/repos/mapbox/mapbox-gl-native/milestones/20/labels","id":1382123,"number":20,"title":"android-v2.3.0","description":"","creator":{"login":"bleege","id":989928,"avatar_url":"https://avatars.githubusercontent.com/u/989928?v=3","gravatar_id":"","url":"https://api.github.com/users/bleege","html_url":"https://github.com/bleege","followers_url":"https://api.github.com/users/bleege/followers","following_url":"https://api.github.com/users/bleege/following{/other_user}","gists_url":"https://api.github.com/users/bleege/gists{/gist_id}","starred_url":"https://api.github.com/users/bleege/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bleege/subscriptions","organizations_url":"https://api.github.com/users/bleege/orgs","repos_url":"https://api.github.com/users/bleege/repos","events_url":"https://api.github.com/users/bleege/events{/privacy}","received_events_url":"https://api.github.com/users/bleege/received_events","type":"User","site_admin":false},"open_issues":68,"closed_issues":26,"state":"open","created_at":"2015-10-28T19:32:12Z","updated_at":"2015-11-03T14:33:58Z","due_on":null,"closed_at":null},"comments":9,"created_at":"2015-09-23T15:02:26Z","updated_at":"2015-11-03T15:03:26Z","closed_at":null,"body":"While investigating #2295 @ljbade discovered that [OkHttp](http://square.github.io/okhttp/) and `uv_async` were not working properly together.  The result was the decision to ship `0.1.0` using `curl` instead.  This ticket will be about restoring OkHttp by working out [the issues with `uv_async` as documented](https://github.com/mapbox/mapbox-gl-native/issues/2295#issuecomment-142465668) by @ljbade.  Specifically:\r\n\r\n>- on curl all completed `HTTPRequest` handling happens in the same thread that creates `HTTPContext` as curl uses a loop pump to process everything (this is enforced via `MBGL_VERIFY_THREAD` macro)\r\n- on NSUrl and OkHTTP we farm `HTTPRequest` out to the system so we get the result back async on a different thread from the one that created `HTTPContext`\r\n- that is why both NSUrl and OkHTTP use `uv_async` to hand the final request processing back to the `HTTPContext` thread\r\n\r\n>So to remove `uv_async` we need an alternative way to get the request back to the `HTTPContext` thread.\r\n\r\n>I think @kkaefer will need to help us here with Option C, or he might be able to persue Option B.\r\n\r\n@incanus @ljbade @kkaefer \r\n\r\n"},"comment":{"url":"https://api.github.com/repos/mapbox/mapbox-gl-native/issues/comments/153381861","html_url":"https://github.com/mapbox/mapbox-gl-native/issues/2400#issuecomment-153381861","issue_url":"https://api.github.com/repos/mapbox/mapbox-gl-native/issues/2400","id":153381861,"user":{"login":"zugaldia","id":6964,"avatar_url":"https://avatars.githubusercontent.com/u/6964?v=3","gravatar_id":"","url":"https://api.github.com/users/zugaldia","html_url":"https://github.com/zugaldia","followers_url":"https://api.github.com/users/zugaldia/followers","following_url":"https://api.github.com/users/zugaldia/following{/other_user}","gists_url":"https://api.github.com/users/zugaldia/gists{/gist_id}","starred_url":"https://api.github.com/users/zugaldia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zugaldia/subscriptions","organizations_url":"https://api.github.com/users/zugaldia/orgs","repos_url":"https://api.github.com/users/zugaldia/repos","events_url":"https://api.github.com/users/zugaldia/events{/privacy}","received_events_url":"https://api.github.com/users/zugaldia/received_events","type":"User","site_admin":false},"created_at":"2015-11-03T15:03:26Z","updated_at":"2015-11-03T15:03:26Z","body":"Not sure why I can't build the `2400-lock` branch, even after `make clean` or `make distclean`. I'll try to reproduce this some other way.\r\n\r\nThis is what I get when trying `make android`:\r\n\r\n```\r\n  AR(target) Release/obj.target/libmbgl-platform-android.a\r\n  COPY Release/libmbgl-platform-android.a\r\n  CXX(target) Release/obj.target/http-android/platform/android/http_request_android.o\r\n../../platform/android/http_request_android.cpp:48:18: error: only virtual member functions can be marked 'final'\r\n    void retry() final;\r\n                 ^~~~~\r\n../../platform/android/http_request_android.cpp:54:34: error: only virtual member functions can be marked 'final'\r\n    void retry(uint64_t timeout) final;\r\n                                 ^~~~~\r\n../../platform/android/http_request_android.cpp:64:5: error: unknown type name 'ResponseStatus'\r\n    ResponseStatus status = ResponseStatus::PermanentError;\r\n    ^\r\n../../platform/android/http_request_android.cpp:86:7: error: no matching constructor for initialization of 'mbgl::HTTPContextBase'\r\n    : HTTPContextBase(loop_),\r\n      ^               ~~~~~\r\n../../src/mbgl/storage/http_context_base.hpp:13:7: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'uv_loop_t *' (aka 'uv_loop_s *') to\r\n      'const mbgl::HTTPContextBase' for 1st argument\r\nclass HTTPContextBase {\r\n      ^\r\n../../src/mbgl/storage/http_context_base.hpp:13:7: note: candidate constructor (the implicit move constructor) not viable: no known conversion from 'uv_loop_t *' (aka 'uv_loop_s *') to\r\n      'mbgl::HTTPContextBase' for 1st argument\r\nclass HTTPContextBase {\r\n      ^\r\n../../src/mbgl/storage/http_context_base.hpp:13:7: note: candidate constructor (the implicit default constructor) not viable: requires 0 arguments, but 1 was provided\r\n../../platform/android/http_request_android.cpp:133:12: error: cannot initialize return object of type 'mbgl::HTTPRequestBase *' with an rvalue of type 'mbgl::HTTPAndroidRequest *'\r\n    return new HTTPAndroidRequest(this, resource, callback, loop_, response);\r\n           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n../../platform/android/http_request_android.cpp:172:14: error: no member named 'addRequest' in 'mbgl::HTTPAndroidContext'\r\n    context->addRequest(this);\r\n    ~~~~~~~  ^\r\n../../platform/android/http_request_android.cpp:176:21: error: exception specification in declaration does not match previous declaration\r\nHTTPAndroidRequest::~HTTPAndroidRequest() {\r\n                    ^\r\n../../platform/android/http_request_android.cpp:45:5: note: previous declaration is here\r\n    ~HTTPAndroidRequest();\r\n    ^\r\n../../platform/android/http_request_android.cpp:177:14: error: no member named 'removeRequest' in 'mbgl::HTTPAndroidContext'\r\n    context->removeRequest(this);\r\n    ~~~~~~~  ^\r\n../../platform/android/http_request_android.cpp:234:23: error: use of undeclared identifier 'ResponseStatus'\r\n        if (status == ResponseStatus::TemporaryError && attempts < maxAttempts) {\r\n                      ^\r\n../../platform/android/http_request_android.cpp:237:30: error: use of undeclared identifier 'ResponseStatus'\r\n        } else if (status == ResponseStatus::ConnectionError && attempts < maxAttempts) {\r\n                             ^\r\n../../platform/android/http_request_android.cpp:242:23: error: use of undeclared identifier 'ResponseStatus'\r\n        if (status == ResponseStatus::NotModified) {\r\n                      ^\r\n../../platform/android/http_request_android.cpp:243:13: error: no matching function for call to object of type 'Callback' (aka 'function<void (std::shared_ptr<const Response>)>')\r\n            notify(std::move(response), FileCache::Hint::Refresh);\r\n            ^~~~~~\r\n/Users/antonio/dev/mapbox/mapbox-gl-native-clean/mason_packages/osx-10.11/android-ndk/arm-9-r10e/bin/../lib/gcc/arm-linux-androideabi/4.9/../../../../include/c++/4.9/functional:1504:9: note: candidate\r\n      function not viable: requires 1 argument, but 2 were provided\r\n    _Rp operator()(_ArgTypes...) const;\r\n        ^\r\n../../platform/android/http_request_android.cpp:245:13: error: no matching function for call to object of type 'Callback' (aka 'function<void (std::shared_ptr<const Response>)>')\r\n            notify(std::move(response), FileCache::Hint::Full);\r\n            ^~~~~~\r\n/Users/antonio/dev/mapbox/mapbox-gl-native-clean/mason_packages/osx-10.11/android-ndk/arm-9-r10e/bin/../lib/gcc/arm-linux-androideabi/4.9/../../../../include/c++/4.9/functional:1504:9: note: candidate\r\n      function not viable: requires 1 argument, but 2 were provided\r\n    _Rp operator()(_ArgTypes...) const;\r\n        ^\r\n../../platform/android/http_request_android.cpp:261:15: error: no member named 'message' in 'mbgl::Response'\r\n    response->message = message;\r\n    ~~~~~~~~  ^\r\n../../platform/android/http_request_android.cpp:272:23: error: no member named 'status' in 'mbgl::Response'\r\n            response->status = existingResponse->status;\r\n            ~~~~~~~~  ^\r\n../../platform/android/http_request_android.cpp:272:50: error: no member named 'status' in 'mbgl::Response'\r\n            response->status = existingResponse->status;\r\n                               ~~~~~~~~~~~~~~~~  ^\r\n../../platform/android/http_request_android.cpp:273:23: error: no member named 'message' in 'mbgl::Response'\r\n            response->message = existingResponse->message;\r\n            ~~~~~~~~  ^\r\n../../platform/android/http_request_android.cpp:273:51: error: no member named 'message' in 'mbgl::Response'\r\n            response->message = existingResponse->message;\r\n                                ~~~~~~~~~~~~~~~~  ^\r\n../../platform/android/http_request_android.cpp:277:22: error: use of undeclared identifier 'ResponseStatus'\r\n            status = ResponseStatus::NotModified;\r\n                     ^\r\nfatal error: too many errors emitted, stopping now [-ferror-limit=]\r\n20 errors generated.\r\nmake[2]: *** [Release/obj.target/http-android/platform/android/http_request_android.o] Error 1\r\nmake[1]: *** [Makefile/androidapp] Error 2\r\nmake: *** [android-lib] Error 2\r\n```\r\n"}}