* Introduce FrameGraphInfo class * Move the assignment into pimpl * Make ctors explicit * Add ctors to fg info structs * Revert the macro change to align with existing * Address the comments * Remove pimpl and move func def to .cc * Fix * Convert the FrameGraph to FrameGraphInfo * Initialize and update debug server on engine side * Fix compile error * Address the comments * Update * Use camelCase * Use camelCase * Update * Add JsonWriter to convert fginfo to json * Add getStatus api and implement it * Add increment * Implement GET apis * Fix compile error * Update * Use c_str_safe * Add operator== for FrameGraphInfo * Call updateFrameGraph in appropriate locations * Address the comments * Add webview for fgviewer * Remove head and tail bracket * Fix the table element * Force web to re-render when fg info gets updated * Skip culled resources * Mark subresources as gray * Add parent info for subresources * Collapse subresources into their parent resource * Make the leftmost column fixed * Remove unused stuff in html * Fix the comment * Refactor the code * Cull unused resources * Update * Fix the naming * Format the file * Fix naming * Address the comments * Address the comment
68 lines
2.1 KiB
JavaScript
68 lines
2.1 KiB
JavaScript
/*
|
|
* Copyright (C) 2025 The Android Open Source Project
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
// api.js encapsulates all the REST endpoints that the server provides
|
|
|
|
async function _fetchJson(uri) {
|
|
const response = await fetch(uri);
|
|
return await response.json();
|
|
}
|
|
|
|
async function _fetchText(uri) {
|
|
const response = await fetch(uri);
|
|
return await response.text();
|
|
}
|
|
|
|
async function fetchFrameGraphs() {
|
|
const fgJson = await _fetchJson("api/framegraphs")
|
|
const ret = {};
|
|
for (const fgInfo of fgJson) {
|
|
ret[fgInfo.fgid] = fgInfo;
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
async function fetchFrameGraph(fgid) {
|
|
const fgInfo = await _fetchJson(`api/framegraph?fgid=${fgid}`);
|
|
fgInfo.fgid = fgid;
|
|
return fgInfo;
|
|
}
|
|
|
|
const STATUS_LOOP_TIMEOUT = 3000;
|
|
|
|
const STATUS_CONNECTED = 1;
|
|
const STATUS_DISCONNECTED = 2;
|
|
const STATUS_FRAMEGRAPH_UPDATED = 3;
|
|
|
|
// Status function should be of the form function(status, data)
|
|
async function statusLoop(isConnected, onStatus) {
|
|
// This is a hanging get except for when transition from disconnected to connected, which
|
|
// should return immediately.
|
|
try {
|
|
const fgid = await _fetchText("api/status" + (isConnected() ? '' : '?firstTime'));
|
|
// A first-time request returned successfully
|
|
if (fgid === '0') {
|
|
onStatus(STATUS_CONNECTED);
|
|
} else if (fgid !== '1') {
|
|
onStatus(STATUS_FRAMEGRAPH_UPDATED, fgid);
|
|
} // fgid == '1' is no-op, just loop again
|
|
statusLoop(isConnected, onStatus);
|
|
} catch {
|
|
onStatus(STATUS_DISCONNECTED);
|
|
setTimeout(() => statusLoop(isConnected, onStatus), STATUS_LOOP_TIMEOUT)
|
|
}
|
|
}
|