Absolute marker URLs fail to load: nftMarkerUrls.push is not a function
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 67/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- typescript
Research direction
Start by reading the URL handling in src/Worker.ts and src/Worker.simd.ts, then check the README Configuration section's addPath row. Exercise absolute and relative marker URLs and cameraPara with and without addPath, using the documented loading debug logs to compare behavior. Done means both workers handle those cases as specified, dist/ and types/ are rebuilt, and the README note is updated.
Written by the indexing model from the issue text.
Description
Bug
Marker paths given as absolute http(s) URLs cannot be loaded. When addPath is empty, the worker assigns the URL to the list instead of adding it, and then throws:
TypeError: nftMarkerUrls.push is not a function
(minified: C.push is not a function, as reported in #278).
In src/Worker.ts, and the same in src/Worker.simd.ts:
let nftMarkerUrls: Array<string> = [];
// ...
const reM = regexM.test(msg.marker);
for (let i = 0; i < markerLength; i++) {
let nftMarkerUrl: string;
if (reM == true) {
if (msg.addPath) {
nftMarkerUrl = basePath + "/" + msg.addPath + "/" + msg.marker[i];
} else {
nftMarkerUrls = msg.marker[i]; // replaces the array with a string
}
} else if (reM == false) {
// ...
}
nftMarkerUrls.push(nftMarkerUrl); // TypeError
}
msg is untyped, so TypeScript does not catch the assignment.
Related problems in the same code
addPathis added to absolute URLs too. WithaddPathset, both the marker paths andcameraParabecomeorigin + "/" + addPath + "/" + patheven when the path is already an absolute URL, which gives an invalid address. #366 documents this in the README (leaveaddPathempty with absolute URLs) as a workaround.- One check for the whole list.
regexM.test(msg.marker)runs once on the whole array (converted to a comma-separated string), so a list mixing relative paths and absolute URLs is handled as if all paths were absolute.
Suggested fix
Resolve each path on its own, with one helper for both the markers and cameraPara:
- an absolute
http(s)URL is used as is, whateveraddPathis; - a relative path keeps the current behaviour:
origin/addPath/path, ororigin/pathwithoutaddPath.
Apply the same change to Worker.simd.ts, rebuild dist/ and types/, and update the addPath row in the README's Configuration section, which will no longer need the "leave it empty" note.
How to check
ARnft.init(...)with a marker on another origin, e.g.https://raw.githack.com/webarkit/ARnft/master/examples/DataNFT/pinball, and noaddPath: the marker loads and tracks;- the same with
addPathset: the absolute URL is not prefixed; - relative markers and
cameraPara, with and withoutaddPath: same URLs as today (see theLoading NFT marker at:andLoading camera at:debug logs).
Fixing this should also close #278.
- Dominant language
- TypeScript
- Stars
- 235
- Forks
- 50
- Avg merge
- 11h 4m
- Merged PRs (30d)
- 13
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from webarkit/ARnft
-
Move CameraViewRenderer to a shared package (@webarkit/camera-view)Possibly taken @kalwalt claimed this 1 day ago. Open:rocket: enhancement code-design documentation Typescript
webarkit/ARnft#370 · 1 assignee ·
Maintainers usually reply within 1 day
-
:rocket: enhancement vite
Difficulty 5/5 Over a week Newbie friendliness 48/100
Maintainers usually reply within 1 day
-
:rocket: enhancement
Difficulty 3/5 1-2 days Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Update @webarkit/jsartoolkit-nft (1.7.7 → 1.13.x) and other dependenciesPossibly taken @kalwalt claimed this 24 days ago. Opendependencies
webarkit/ARnft#355 · 1 comment · 1 assignee ·
Maintainers usually reply within 1 day
-
code-design question
Difficulty 5/5 Over a week Newbie friendliness 35/100
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
Clouditera/VulnHunter#57 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
bug bug:behavior clawsweeper:bulk-filed clawsweeper:fix-shape-clear clawsweeper:no-new-fix-pr clawsweeper:source-repro impact:auth-provider issue-rating: 🦞 diamond lobster P2
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
openclaw/openclaw#185297 · 1 comment · 1 reaction ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
-
bug needs-triage
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
apex-dev-tools/apex-log-parser#199 ·
Maintainers usually reply within 1 day