"Unhandled declaration" in production
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 32/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- javascript, next.js
調査の方向性
ドキュメントに記載された Next.js のセットアップで、CDN から gpu.js v2.15.2 を読み込み、提供されている kernel コードを使用して失敗を再現します。開発ビルドと next build および next export の出力を比較し、gpu-browser.js 内の Unhandled declaration stack に注目します。本番の静的サイトでこの kernel をエラーなしに実行できれば完了です。
索引モデルが issue の本文から書いたものです。
説明

What is wrong?
I get the following error when trying to use gpu.js on production (optimized code):
Uncaught Error: Unhandled declaration
at WebGL2FunctionNode.astVariableDeclaration (gpu-browser.js:12600:17)
at WebGL2FunctionNode.astGeneric (gpu-browser.js:8023:23)
at WebGL2FunctionNode.astBlockStatement (gpu-browser.js:12555:14)
at WebGL2FunctionNode.astGeneric (gpu-browser.js:8007:23)
at WebGL2FunctionNode.astForStatement (gpu-browser.js:12455:12)
at WebGL2FunctionNode.astGeneric (gpu-browser.js:8017:23)
at WebGL2FunctionNode.astFunction (gpu-browser.js:11962:12)
at WebGL2FunctionNode.astFunctionExpression (gpu-browser.js:8095:17)
at WebGL2FunctionNode.astGeneric (gpu-browser.js:7991:23)
at WebGL2FunctionNode.toString (gpu-browser.js:7437:32)
Where does it happen?
On my static website built with Next.js that loads gpu.js from CDN. However, it perfectly works on local server with unoptimized code in a dev mode.
How do we replicate the issue?
- Create Next.js project.
- Add gpu.js script tag to the
_document.js:<Script src="https://unpkg.com/[email protected]/dist/gpu-browser.js" strategy="beforeInteractive" /> - Build the project with
next build(npm run build). - Generate static website with
next export. - Host the static website on a server and try to use gpu.js there.
I suppose babel does something with my kernel code, idk.
How important is this (1-5)?
4
Other Comments
I use gpu.js v2.15.2. Here is my kernel code. Seems like nothing special:
const createKernel = outputLength => new window.GPU({
mode: "gpu",
}).createKernel(
function (videoPixels, emojiPixels, emojiPixelsLength, brightness) {
let lowestDistanceIn3d = Infinity
let lowestDistanceEmojiPixelIndex = 0
for (let j = 0, i = 0; j < emojiPixelsLength; j += 3) {
const emojiPixel = [emojiPixels[j], emojiPixels[j + 1], emojiPixels[j + 2]]
const videoPixelOffset = this.thread.x * 4
const videoPixel = [
videoPixels[videoPixelOffset],
videoPixels[videoPixelOffset + 1],
videoPixels[videoPixelOffset + 2],
]
const distanceIn3d = Math.sqrt(
Math.pow(emojiPixel[0] - videoPixel[0] * brightness, 2) +
Math.pow(emojiPixel[1] - videoPixel[1] * brightness, 2) +
Math.pow(emojiPixel[2] - videoPixel[2] * brightness, 2)
)
if (lowestDistanceIn3d > distanceIn3d) {
lowestDistanceIn3d = distanceIn3d
lowestDistanceEmojiPixelIndex = i
}
i++
}
return lowestDistanceEmojiPixelIndex
},
{
output: [outputLength],
loopMaxIterations: 9999999,
}
)
- 主要言語
- 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
-
feature task
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
RealDevSquad/website-www#1178 ·
-
add latest sol modelオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
netlify-labs/nax#56 · コメント 2 件 · リアクション 1 件 ·
-
accessibility bug revealjs
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
quarto-dev/quarto-cli#14961 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
PnX-SI/GeoNature#4435 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
openlayers/openlayers#17648 ·
メンテナーはふだん 1 日以内に返信