[node] Output debug logs when a render test times out
This commit is contained in:
@@ -170,6 +170,7 @@ public:
|
||||
void toggleCollisionDebug();
|
||||
bool getCollisionDebug() const;
|
||||
bool isFullyLoaded() const;
|
||||
void dumpDebugLogs() const;
|
||||
|
||||
private:
|
||||
View& view;
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
],
|
||||
"devDependencies": {
|
||||
"aws-sdk": "^2.2.9",
|
||||
"mapbox-gl-test-suite": "git+https://github.com/mapbox/mapbox-gl-test-suite.git#5ede718acddd3be1a736249ab6c6c0707f9f71f3",
|
||||
"mapbox-gl-test-suite": "git+https://github.com/mapbox/mapbox-gl-test-suite.git#4931d2b99894e1e02c0a1cc28becdb0546d356ed",
|
||||
"request": "^2.65.0",
|
||||
"tape": "^4.2.1"
|
||||
},
|
||||
|
||||
@@ -47,6 +47,7 @@ NAN_MODULE_INIT(NodeMap::Init) {
|
||||
Nan::SetPrototypeMethod(tpl, "load", Load);
|
||||
Nan::SetPrototypeMethod(tpl, "render", Render);
|
||||
Nan::SetPrototypeMethod(tpl, "release", Release);
|
||||
Nan::SetPrototypeMethod(tpl, "dumpDebugLogs", DumpDebugLogs);
|
||||
|
||||
constructor.Reset(tpl->GetFunction());
|
||||
Nan::Set(target, Nan::New("Map").ToLocalChecked(), tpl->GetFunction());
|
||||
@@ -327,6 +328,14 @@ void NodeMap::release() {
|
||||
map.reset(nullptr);
|
||||
}
|
||||
|
||||
NAN_METHOD(NodeMap::DumpDebugLogs) {
|
||||
auto nodeMap = Nan::ObjectWrap::Unwrap<NodeMap>(info.Holder());
|
||||
|
||||
if (!nodeMap->isValid()) return Nan::ThrowError(releasedMessage());
|
||||
|
||||
nodeMap->map->dumpDebugLogs();
|
||||
info.GetReturnValue().SetUndefined();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Instance
|
||||
|
||||
@@ -26,6 +26,7 @@ public:
|
||||
static NAN_METHOD(Load);
|
||||
static NAN_METHOD(Render);
|
||||
static NAN_METHOD(Release);
|
||||
static NAN_METHOD(DumpDebugLogs);
|
||||
|
||||
void startRender(std::unique_ptr<NodeMap::RenderOptions> options);
|
||||
void renderFinished();
|
||||
@@ -38,7 +39,6 @@ public:
|
||||
static std::unique_ptr<NodeMap::RenderOptions> ParseOptions(v8::Local<v8::Object>);
|
||||
static Nan::Persistent<v8::Function> constructor;
|
||||
|
||||
private:
|
||||
NodeMap(v8::Local<v8::Object>);
|
||||
~NodeMap();
|
||||
|
||||
|
||||
@@ -10,6 +10,10 @@ if (process.argv[1] === __filename && process.argv.length > 2) {
|
||||
tests = process.argv.slice(2);
|
||||
}
|
||||
|
||||
mbgl.on('message', function(msg) {
|
||||
console.log('%s (%s): %s', msg.severity, msg.class, msg.text);
|
||||
});
|
||||
|
||||
suite.run('native', {tests: tests}, function (style, options, callback) {
|
||||
var map = new mbgl.Map({
|
||||
ratio: options.pixelRatio,
|
||||
@@ -20,9 +24,18 @@ suite.run('native', {tests: tests}, function (style, options, callback) {
|
||||
}
|
||||
});
|
||||
|
||||
var timedOut = false;
|
||||
var watchdog = setTimeout(function () {
|
||||
timedOut = true;
|
||||
map.dumpDebugLogs();
|
||||
callback(new Error('timed out after 20 seconds'));
|
||||
}, 20000);
|
||||
|
||||
map.load(style);
|
||||
map.render(options, function (err, pixels) {
|
||||
map.release();
|
||||
if (timedOut) return;
|
||||
clearTimeout(watchdog);
|
||||
callback(err, pixels);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -500,4 +500,8 @@ void Map::onLowMemory() {
|
||||
context->invoke(&MapContext::onLowMemory);
|
||||
}
|
||||
|
||||
void Map::dumpDebugLogs() const {
|
||||
context->invokeSync(&MapContext::dumpDebugLogs);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -324,4 +324,15 @@ void MapContext::onResourceLoadingFailed(std::exception_ptr error) {
|
||||
}
|
||||
}
|
||||
|
||||
void MapContext::dumpDebugLogs() const {
|
||||
Log::Info(Event::General, "--------------------------------------------------------------------------------");
|
||||
Log::Info(Event::General, "MapContext::styleURL: %s", styleURL.c_str());
|
||||
if (style) {
|
||||
style->dumpDebugLogs();
|
||||
} else {
|
||||
Log::Info(Event::General, "no style loaded");
|
||||
}
|
||||
Log::Info(Event::General, "--------------------------------------------------------------------------------");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -67,6 +67,8 @@ public:
|
||||
void onTileDataChanged() override;
|
||||
void onResourceLoadingFailed(std::exception_ptr error) override;
|
||||
|
||||
void dumpDebugLogs() const;
|
||||
|
||||
private:
|
||||
// Update the state indicated by the accumulated Update flags, then render.
|
||||
void update();
|
||||
|
||||
@@ -594,4 +594,13 @@ void Source::emitTileLoadingFailed(const std::string& message) {
|
||||
observer_->onTileLoadingFailed(error);
|
||||
}
|
||||
|
||||
void Source::dumpDebugLogs() const {
|
||||
Log::Info(Event::General, "Source::id: %s", info.source_id.c_str());
|
||||
Log::Info(Event::General, "Source::loaded: %d", loaded);
|
||||
|
||||
for (const auto& tile : tiles) {
|
||||
tile.second->data->dumpDebugLogs();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -91,6 +91,7 @@ public:
|
||||
void onLowMemory();
|
||||
|
||||
void setObserver(Observer* observer);
|
||||
void dumpDebugLogs() const;
|
||||
|
||||
SourceInfo info;
|
||||
bool enabled;
|
||||
|
||||
@@ -111,4 +111,8 @@ void Sprite::setObserver(Observer* observer_) {
|
||||
observer = observer_;
|
||||
}
|
||||
|
||||
void Sprite::dumpDebugLogs() const {
|
||||
Log::Info(Event::General, "Sprite::loaded: %d", loaded);
|
||||
}
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -34,6 +34,8 @@ public:
|
||||
return loaded;
|
||||
}
|
||||
|
||||
void dumpDebugLogs() const;
|
||||
|
||||
const float pixelRatio;
|
||||
|
||||
void setObserver(Observer* observer);
|
||||
|
||||
@@ -23,4 +23,10 @@ const char* TileData::StateToString(const State state) {
|
||||
}
|
||||
}
|
||||
|
||||
void TileData::dumpDebugLogs() const {
|
||||
Log::Info(Event::General, "TileData::id: %s", std::string(id).c_str());
|
||||
Log::Info(Event::General, "TileData::state: %s", TileData::StateToString(state));
|
||||
Log::Info(Event::General, "TileData::error: %s", error.c_str());
|
||||
}
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -91,6 +91,8 @@ public:
|
||||
return error;
|
||||
}
|
||||
|
||||
void dumpDebugLogs() const;
|
||||
|
||||
const TileID id;
|
||||
|
||||
// Contains the tile ID string for painting debug information.
|
||||
|
||||
@@ -262,4 +262,16 @@ void Style::emitResourceLoadingFailed(std::exception_ptr error) {
|
||||
}
|
||||
}
|
||||
|
||||
void Style::dumpDebugLogs() const {
|
||||
for (const auto& source : sources) {
|
||||
source->dumpDebugLogs();
|
||||
}
|
||||
|
||||
if (!sprite) {
|
||||
Log::Info(Event::General, "no sprite loaded");
|
||||
} else {
|
||||
sprite->dumpDebugLogs();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -69,6 +69,8 @@ public:
|
||||
void addLayer(util::ptr<StyleLayer>, const std::string& beforeLayerID);
|
||||
void removeLayer(const std::string& layerID);
|
||||
|
||||
void dumpDebugLogs() const;
|
||||
|
||||
MapData& data;
|
||||
std::unique_ptr<GlyphStore> glyphStore;
|
||||
std::unique_ptr<GlyphAtlas> glyphAtlas;
|
||||
|
||||
Reference in New Issue
Block a user