Skip to content

fix: Load smart item asset path #1062

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 6, 2025
Merged

fix: Load smart item asset path #1062

merged 3 commits into from
Feb 6, 2025

Conversation

cyaiox
Copy link
Collaborator

@cyaiox cyaiox commented Feb 6, 2025

Asset Loading Race Condition Fix

Context and Problem Statement

When dragging and dropping assets (particularly NFTs and smart items) into the canvas, there was a race condition where the asset would fail to load on the first attempt but succeed on subsequent attempts. This occurred because the asset was requested before it was fully downloaded and available in the filesystem.

Solution

Implemented a retry mechanism in the SceneContext.getFile() method to handle cases where an asset is temporarily unavailable. This provides a more robust solution without introducing unnecessary complexity.

Key changes:

  • Added retry logic to getFile() with a maximum of 3 attempts
  • Added 500ms delay between retries to allow for asset availability
  • Improved error logging for debugging purposes

Testing

  • Tested dragging and dropping NFTs - works on the first attempt
  • Tested dragging and dropping Video Player - works on the first attempt
  • Tested dragging and dropping smart items - works on the first attempt
  • Verified retry mechanism works with console logging
  • Confirmed no regressions in other asset loading scenarios

Impact

This change improves the reliability of asset loading in the Inspector, particularly for NFTs and smart items. Users will no longer experience failed first attempts when dragging and dropping these assets into the canvas.

Closes: decentraland/creator-hub#346

Copy link
Contributor

github-actions bot commented Feb 6, 2025

Test this pull request

  • The @dcl/sdk package can be tested in scenes by running

    npm install "https://sdk-team-cdn.decentraland.org/@dcl/js-sdk-toolchain/branch/fix/smart-item-asset-path/dcl-sdk-7.7.4-13181398394.commit-d278f8d.tgz"
  • To test with npx init

    export SDK_COMMANDS="https://sdk-team-cdn.decentraland.org/@dcl/js-sdk-toolchain/branch/fix/smart-item-asset-path/dcl-sdk-commands-7.7.4-13181398394.commit-d278f8d.tgz"
    npx $SDK_COMMANDS init
  • The @dcl/inspector package can be tested by visiting this url

    • Or by installing it via NPM
    npm install "https://sdk-team-cdn.decentraland.org/@dcl/js-sdk-toolchain/branch/fix/smart-item-asset-path/@dcl/inspector/dcl-inspector-7.7.4-13181398394.commit-d278f8d.tgz"
  • The /changerealm command to test test in-world

    /changerealm https://sdk-team-cdn.decentraland.org/ipfs/fix/smart-item-asset-path-e2e
    
  • You can preview this build entering:
    https://playground.decentraland.org/?sdk-branch=fix/smart-item-asset-path

Copy link

cloudflare-workers-and-pages bot commented Feb 6, 2025

Deploying js-sdk-toolchain with  Cloudflare Pages  Cloudflare Pages

Latest commit: 8f278e1
Status: ✅  Deploy successful!
Preview URL: https://a0a9f9de.js-sdk-toolchain.pages.dev
Branch Preview URL: https://fix-smart-item-asset-path.js-sdk-toolchain.pages.dev

View logs

@cyaiox cyaiox enabled auto-merge (squash) February 6, 2025 14:57
@cyaiox cyaiox merged commit 2b88243 into main Feb 6, 2025
8 checks passed
@cyaiox cyaiox deleted the fix/smart-item-asset-path branch February 6, 2025 14:59
gonpombo8 added a commit that referenced this pull request Mar 27, 2025
* chore: update readmes (#1054)

* chore: update readmes

* Update packages/@dcl/ecs/README.md

Co-authored-by: Gon Pombo <[email protected]>
Signed-off-by: Juan Cazala <[email protected]>

---------

Signed-off-by: Juan Cazala <[email protected]>
Co-authored-by: Gon Pombo <[email protected]>

* add filters for asset explorer (#1056)

* add filters for asset explorer

* use decentraland/oddish-action

* move 'Filter' to enum

* move IAsset type determination to fn

* fix several issues with import files (#1059)

* fix race condition when validating models on import

* add 'VALUE_NOT_IN_RANGE' to ignored model errors

* fix import button on asset explorer styles

* move feeded fs example model to Models/example/model.glb

* reset the FileInput value so the same file can be selected again

* fix import file size + extension validation (#1060)

* change max file import size to 50mb

* allow all extensions on FileInput to show errors on Error modal

* fix: Load smart item asset path (#1062)

* fix: Load smart items path

* fix: Add a small retry when fetching the models to avoid race conditions

* fix: Linter

* fix: handle new categories without breaking (#1058)

* fix Animator component initialization (#1061)

* fix network entities for the editor (#1069)

* fix network entities for the editor

* fix tests & lint

* fix tests

* feat: Make createReactBasedUiSystem public (#1063)

* feat: Make createReactBasedUiSystem public

* fix: playground-assets.api.md

* feat: Send PlayersHelpers to the initAssetPacks method

* feat: Update BasicView Actions to handle TextArea fields (#1064)

* Fix/dropdown input result callbacks (#1071)

* fix uiDropdown not being updated

* fix tests

* fix test COVERAGE

* remove unnecessary return

* wip test

* move 'spawn' ts checker to 'fork' (#1074)

* fix several issues (#1072)

* fix scroll on assets catalog

* fix tooltip link on Action & Trigger components

* deprecate alphaTexture on PBR & add it to unlit materials

* replace 'ctrl' for '⌘' on shortcuts when necessary

* add 'global' prop to AudioSource

* feat: avatarTarget param addition in movePlayerTo() (#1073)

* feat: Add AdminTools Smart Item (#1066)

* WIP

* feat: Export components Accordion and CheckboxGroup

* fix: Update type of AddButton

* feat: Add AdminTools Rewards Control Inspector

* feat: Add AdminTools Video Control Inspector

* feat: Add AdminTools Smart Items Control Inspector

* feat: Remove unused code

* chore: Use dev @dcl/asset-packs package

* chore: Update dependencies

* wip

* wip

* fix: Config

* chore: Update @dcl/asset-packs dependency

* feat: Update Pill padding styles

* feat: Update VideoControl styles

* feat: Move TextAnnouncementControl section to a new component

* feat: Update SmartItemControl styles

* feat: Update RewardsControl styles

* feat: Move AdminAllowListControl section to a new component

* feat: Refactor AdminToolkitView

* chore: Update @dcl/asset-packs version

* feat: Add border styles to the Accordion component

* fix: AdminTools styles

* refactor: RewardInspector component form to a new component

* feat: Add RewardsBasicView component for Collectible Dispenser

* feat: Add AdminToolsBasicView for AdminTools

* fix: lint

* fix: Rewards component visibility

* feat: Add InfoTooltip for the AdminTools view

* eat: Add InfoTooltip for the Rewards view

* fix: Typo in Admin Text announcements control

* fix: Prioritize Video Control over Text Announcements

* fix: Rewards URL env

* chore: Update @dcl/asset-packs version

* chore: Update @dcl/asset-packs version

* fix: Lint

* feat: Add  parentEntity, removeParent, getParent, getChildren methods to the initAssetPacks init

* fix: Update asset-packs

* fix: Bundle

* fix: Update asset-packs

* fix: Update asset-packs

* fix: Update asset-packs

* fix: Update asset-packs

* fix: Remove link all screens and show author checkboxes

* fix: Remove link all smart items handler

* fix: Remove Airdrops section

* fix: Show action Claim Airdrop only when the entity has the Rewards component

* fix: Update asset-packs

* fix: Update asset-packs

* fix: Doesn't allow add rows

* fix: AvailableActions Map

* fox: Remove validation for dev

* update asset-packs

---------

Co-authored-by: Gonzalo DCL <[email protected]>

* bump asset-packs 2.2.1 (#1077)

* update left/right click button behaviour on renderer (#1078)

* update left/right click button behaviour on renderer

* remove gizmo right click button

* fixed review comments

* remove desktop client (OLD) option (#1083)

* select "Scene" in tree on startup (#1082)

* update left/right click button behaviour on renderer

* select 'Scene' in tree on startup

* add refresh button for Assets (#1085)

* support border in uitransforms (#1084)

* support border in uitransforms

* fix build

* change protocol to experimental

* use main protocol

* fix snapshots test

* fix tests

* fix coverage

* update protocol

---------

Signed-off-by: Juan Cazala <[email protected]>
Co-authored-by: Juan Cazala <[email protected]>
Co-authored-by: Nicolas Echezarreta <[email protected]>
Co-authored-by: Gabriel Díaz <[email protected]>
Co-authored-by: Pravus <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NFT Smart Item lacks model/graphic when added
2 participants