Debug in preview
Running a preview provides some useful debugging information and tools to help you understand how the scene is rendered. The preview mode provides indicators that show parcel boundaries and the orientation of the scene.
If the scene can’t be compiled, you’ll just see the grid on the ground, with nothing rendered on it.
If this occurs, there are several places where you can look for error messages to help you understand what went wrong:
- Check your code editor to make sure that it didn’t mark any syntax or logic errors.
- Check the output of the command line where you ran
npm run start
- Check the console in the preview window for any other error messages. Toggle the console by pressing the ` key on your keyboard.
💡 Tip: Before you deploy your scene to the production environment, deploy it to the test environment to try it in a context that is a lot closer to production. See Development Workflow
Use the console #
Output messages to console (using console.log()
). You can then view these messages as they are generated by opening the scene console. Toggle the console by pressing the backtick key on your keyboard: `. This key is left of the 1 key on most english language keyboards.
You can also press Shift + ` to open a wider view of the console, in case you need to view more text.
You can also add debugger
commands or use the sources
tab in the developer tools menu to add breakpoints and pause execution while you interact with the scene in real time.
View scene stats #
Open the scene’s stats by running /debug
on the chat panel. This opens a panel with information about the renderer engine, and is updated in real time as things change.
Frame rate #
The PERFORMANCE tab includes several fields related to FPS (Frames Per Second). This value will tend to be lower as the scene grows in complexity, make sure you always keep this value above 25 FPS, to ensure a good experience for your players. The FPS will vary depending on the machine you run this in.
📔 Note: The renderer’s FPS is not the same as the scene’s updates of the game loop per second. The scene’s logic is capped at 30 FPS, the renderer’s FPS can go up to 60 or more.
Hiccups refer to momentary pauses in the frame rate, which might have little impact in the overall FPS number but can be very noticeable to the player. These can typically occur when heavy assets are loaded or similar.
Memory #
The MEMORY section displays the memory used by Decentraland. Always try to keep this value below the Memory Budget Thresholds. If this value grows too much, it risks crashing the explorer for players visiting your scene. Keep in mind that in production, the scene might be loaded together with other surrounding scenes and players, which can all contribute to raise the memory consumption higher than what you see in preview.
Quick reload #
If you need to reload the scene you’re standing on, write the following into the chat and push enter:
/reload
Report a bug #
If you encounter a problem that is not with your scene, but instead with the Decentraland SDK in general, please see Report a bug .
Dependency versions #
Make sure you always use the latest versions of all dependencies in your scene, as any issues you’re experiencing might already be fixed in newer versions. The Creator Hub will notify you when there are updates to install on your Decentraland scene.
Running a Decentraland scene locally depends on two main libraries: @dcl/sdk
and @dcl/js-runtime
, which is installed on each project folder. Make sure both of those are up to date. You can run the following commands to manually update both these libraries to the latest stable version:
npm i @dcl/js-runtime@latest
npm i @dcl/sdk@latest
If your scene uses smart items, it may also be using the @dcl/asset-packs
library, which you can update via:
npm i @dcl/asset-packs@latest
If you’re using any of the
utils libraries
make sure those are also up to date, as older versions of these libraries may not be compatible with newer versions of @dcl/sdk
.
Avatars and accounts #
When opening a preview, you connect via your Metamask account, so you can have access to all your owned wearables and tokens.
📔 Note: When running a preview with the legacy web explorer, by default you run with a guest account. You’re assigned a random base avatar each time you reload.
To run a web preview with a Web3 account with the CLI, start the preview with:
npm run start -- --web3
Alternatively, you can manually add the URL parameter
&ENABLE_WEB3
to the URL in the browser window.
Network traffic #
If your scene interacts with a third party server, it’s often useful to see what data goes in and out.
For this, there are several free tools you can run on your machine that report all the data coming in and out of the Decentraland application.
Using the Ethereum test network #
You can avoid using real currency while previewing the scene. For this, you must use the Ethereum Sepolia test network and transfer fake MANA instead. To use the test network you must set your Metamask Chrome extension to use the Sepolia test network instead of Main network. You must also own MANA in the Sepolia blockchain, which you can acquire for free from Decentraland.
Any transactions that you accept while viewing the scene in this mode will only occur in the test network and not affect the MANA balance in your real wallet.
Multiplayer testing #
📔 Note: Currently you can only open one window at a time for the desktop explorer.
When opening the web explorer, if you open a second preview window on your machine, you will enter the scene with a different avatar. The avatars on both tabs will be able to see each other and interact, although currently they might have inconsistent names and wearables on.
📔 Note: You can’t open multiple tabs using the same account. So if your URL has a hardcoded PLAYER
parameter with the same string on multiple tabs, or you’re connecting to Metamask on more than one tab, it won’t be possible to load them all. Each simultaneous tab should load a different account.
If the scene uses the MessageBus to send messages between players, these will work between the different tabs.
If the scene connects to a third party server via websockets, these connections should also work independently on each tab, as separate players.