JSON prebuild export and import broken?
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 35/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- javascript
- 領域
- compilers
調査の方向性
createKernelMap と toJSON/fromJSON エントリポイントから始め、次に map 関数と native 関数に対する FunctionNode の処理を調査します。issue に記載されたエクスポート/インポートのシーケンスを再現し、コンパイルされた fragment shader の出力を追跡します。map の戻り値とカスタム native 関数を含む kernel を、map 結果変数が欠落することなくエクスポート、インポート、コンパイルできれば完了です。
索引モデルが issue の本文から書いたものです。
説明
What is wrong?
To make the loading time faster, I thought to prebuild my kernels once as JSON with toJSON(), and use this JSON to create my MapKernels. But the toJSON() is out of date (not handling native functions correct), and also the intern fromJSON(...) do not work. I tried to patch them, and now I can export, but I don't get the import working.
Additional information: I use a map function with some map return values, and custom native functions.
Where does it happen?
Not specific to a system.
How do we replicate the issue?
- Create a kernel with createKernelMap(...)
- Use at least one map function
- Use at least one native function
- Export the kernel with toJSON()
- Try to create a new kernel with that JSON.
How important is this (1-5)?
2
Expected behavior (i.e. solution)
Should work
Other Comments
After some tests to patch fromJSON(...) I got it working, but the compiled fragment shader complains about complains about the missing map result variables.
Here are my patched functions:
toJSON = function() {
return this.traceFunctionCalls(this.rootNode.name).reverse().map(name => {
const nativeIndex = this.nativeFunctionNames.indexOf(name);
if (nativeIndex > -1) {
return {
name,
source: this.nativeFunctions[nativeIndex].source
};
} else if (this.functionMap[name]) {
return this.functionMap[name].toJSON();
} else {
throw new Error(`function ${ name } not found`);
}
});
}
fromJSON = function(jsonFunctionNodes, FunctionNode) {
this.functionMap = {};
for (let i = 0; i < jsonFunctionNodes.length; i++) {
const jsonFunctionNode = jsonFunctionNodes[i];
if (jsonFunctionNode.settings) {
const functionNode = new FunctionNode(jsonFunctionNode.ast, jsonFunctionNode.settings);
functionNode.triggerImplyArgumentType = this.assignArgumentType.bind(this);
// For some reason the FunctionNode object is missing some members, which I found in the FunctionBuilder.
// I'm not sure, if this is correct, but it works somehow.
for (const key of Object.keys(functionNode)) {
if (functionNode[key] === null && this[key] && typeof this[key] === 'function') {
functionNode[key] = this[key].bind(this);
}
}
this.addFunctionNode(functionNode);
if (functionNode.isSubKernel) {
this.subKernelNodes.push(functionNode);
}
this.functionNodes.push(functionNode);
} else {
this.nativeFunctions.push(jsonFunctionNode);
}
}
return this;
};
- 主要言語
- JavaScript
- スター
- 15.5k
- フォーク
- 663
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
gpujs/gpu.js のほかの issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 65/100
-
WebGL backend silently returns all zeros for long-running kernels (no GL error, no context loss)オープン
難易度 5/5 1週間以上 初心者へのやさしさ 42/100
-
難易度 5/5 1週間以上 初心者へのやさしさ 20/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
似ている issue
-
Complexity: Small P-Feature: Projects page ready for merge team role: back end/devOps role: front end size: 0.25pt
難易度 1/5 1〜3時間 初心者へのやさしさ 88/100
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 67/100
bellingcat/toolkit#905 ·
-
self-care self-care:docs-build-time-investigator
難易度 2/5 半日 初心者へのやさしさ 76/100
githubnext/gh-aw-cao#14191 ·
メンテナーはふだん 1 日以内に返信
-
effort:low impact:medium RAG status: auto-triaged
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
mastra-ai/mastra#25229 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
sugarlabs/musicblocks#8984 ·
メンテナーはふだん 1 日以内に返信