Error After Loading To Another Space

Hi,

I’m building an AR experience in the Cloud Studio Editor. I faced an issue that whenever I press the button that load space to another space, it will show the errors of:

Error: Failed to establish cursor 
at NS runtime.js 
at (anonymous) runtime.js 
at K runtime.js 
at Object.tick runtime.js 
at l runtime.js 
at (anonymous) runtime.js 
at B runtime.js

The issue only encountered after any my level’s feature is completed. I tried to press the same button without proceeding the level’s feature, it doesn’t have the error.

We also tried to load the targeted space from a light weighted and empty spaces with the same button, it doesn’t have the error as well.

The error only encountered on a mobile devices, simulator has no issue. Is it possible to be a memory issue?

Is that any way I can further debug on this issue? Or any helps would be great.

Thanks a lot for any assistance in advance!

Hi, welcome to the forum!

Can you land your changes and share the project with the support workspace so I can take a look?

Hi there,

I have landed the changes and shared the project with the support. The project name: “AR The Legend of Taming Sari”

Do let me know if you required anything further.

Thanks!

Just want to start off by saying this project is AWESOME! Can you let me know which Space has the issue or is it any space?

Hi! Thanks!

Is actually happened in any of the space other than world map, starting space and AR Scene (A space that is shared).

Any of the space we called it as “Level space” that will transit back to world map after the level is completed. The error is encountered at the transition period.

You may start it up from any space other than world map, starting space and AR Scene to check out the error. To test it, you may test it on our first level which is herb & spice space and go through the dialogues and defeat the enemy, then it should show you the button (that caused the error) to transit to world space.

Updates today:

We have a run through debugging session today. It seems like “world.space.loadspace” caused the error whenever we load from/to a space that contains a heavy UI which is the “Dialogue UI” you could see in the level space. From that, we have reduced the assets size by half. However, the error is still appear. We also noticed that, if we continue the flows it will have potential shows “Memory out of bounds”. The error only happened on a mobile device. We are still struggling on figuring out what’s the actual issue.

Do let me know if you required anything further.

Thanks!

I’m able to reproduce the issue on different devices. I’ll forward this to the engineering team for further investigation.

1 Like

Hi there,

Thanks for the investigation. May I know when could we expected to receive any updates from your side?

Our current finding is still the world.spaces.loadspace causing the error. Worst case scenario, once button is pressed, the “Failed to establish cursor” shows up, then transferred back to world map, it will “memory out of bounds”. Better case scenario, it can proceed with few station then “memory out of bounds” shows up. We tried to removed all the looping codes that we had, it still has the same issue. The only things that will not have this error is that completely a blank space or a lighter space without much objects/items (which is not what we wanted).

Thanks in advance!

The team is currently investigating the cause. Based on the behavior I’m seeing, my guess is that there may be a memory leak in the map tile worker or something similar within the world map entity that’s leading to the out-of-memory crash.

As a test, could you try removing the map from the project entirely (you could even duplicate the project to do this) and see if you still experience out-of-memory crashes?

Hi,

Thanks for the update. We have tried the removing the map and implemented a temporary load to our targeted level scene with flows. The outcome is yes, it does run smoother than what we had before. However, it still “memory out bound” if after few different spaces (From our testing, it was on the 5th space onwards).

Uncaught RuntimeError: memory access out of bounds
    at flecs_table_disconnect_edge 007a2222:wasm-function[3013]:0x152530
    at flecs_table_clear_edges 007a2222:wasm-function[3012]:0x15233c
    at flecs_table_fini 007a2222:wasm-function[2950]:0x14db37
    at flecs_id_record_release_tables 007a2222:wasm-function[2932]:0x14c131
    at flecs_on_delete 007a2222:wasm-function[2524]:0x129cf4
    at ecs_delete 007a2222:wasm-function[2515]:0x128b9e
    at c8EmAsm_deleteEntity 007a2222:wasm-function[38]:0x3275
    at Object.<anonymous> runtime.js
    at aK runtime.js
    at Object.deleteEntity runtime.js

The error encountered after load space button is pressed in the inventory UI.

As for the problem of ‘Failed to establish cursor’ after load scene is remain unresolved on mobile devices. We also started noticed that some of the input event starting not capturing when we goes by flows. Example, ecs.input.UI_CLICK after the second space but if we run it individual it does able to interact.

 Uncaught Error: Failed to establish cursor
    at i runtime.js
    at Object.cursor runtime.js
    at Object.prepareCallback runtime.js
    at SS runtime.js
    at ok runtime.js
    at (anonymous) runtime.js
    at (anonymous) runtime.js
    at F runtime.js
    at J runtime.js

Additionally, we landed a new version. The new landed version is further optimized images to smaller resolution. However, the error still encountered.

Thanks in advance.

Hi there,

Just to let you know the finding today. As we run more test around the project. From empty space, temporary space, the original space and disable map from world map and enable map from world map.

We faced random memory out of bounds. The memory out of bounds is logged in “load-space-on-click.ts”:

          setTimeout(() => {
            try {
              console.log('loading space', spaceName)
              world.spaces.loadSpace(spaceName)
            } catch (e) {
              console.error('failed to load space', e)
            } finally {
              state.isLoading = false
            }
          }, 1000)

and in “world-map-ui.ts”

        setTimeout(async () => {
          try {
            console.log(`Load Space ${spaceName}`)
            await world.spaces.loadSpace(spaceName)
          } catch (ex) {
            console.error('Failed to load space:', ex)
          }
        }, 5000)

This is what it shows:

Screenshot 2025-10-01 at 5.13.06 PM

These issue happened randomly with and without the map. It could happened during first and any time of loading another space.

Then as for UI_CLICK, with the same code provided. If we run the space individually on the third space called “Fantasy Planet”, the button works fine. However, if we load from world map to the space, the button unable to press. This happened for simulation and any mobile devices as well. We also tried to work around by adding another more buttons to load the feature, but it still doesn’t work.

With that, we unable to find out where’s the issue from as it happened randomly. Most of the assets is now under 1024 resolution.

For your reference, we have landed “ForSupportV2” in the recent land for you to reference the current code base. We do hope that could get any answer from your side.

Thanks!

Thank you, this is extremely helpful. I will share this with the team as well.

Hi there,

I’m here again :grinning_face_with_smiling_eyes: Hopefully you won’t get bored on my post.

As for today findings after more tries around, we received more errors without any code changes such as this:

This is difficult to be reproduce as it only happened few times during our testing.

When any errors is appears the screen goes:

and the worst case is browser will be browser crash:

As for today, we are still figuring out what could be wrong. However, we are still have no clue in this stage. Another note to point out is that these errors happened after the update of Runtime version 2.x.x, but even we switch back to version 1.x.x it doesn’t fix anything. But I will leave it here if it does help the investigation further.

Thanks!

Hi!

I’ve taken a look at the space switching logic and it looks like there might have been an invalid cursor which could be the source of the issue. Here is the fixed version:

import * as ecs from '@8thwall/ecs'

ecs.registerComponent({
  name: 'Load Space on Click',
  schema: {
    spaceName: ecs.string,
    hideUIOnClick: ecs.boolean,
    hideInventoryOnClick: ecs.boolean,
    inventoryUI: ecs.eid,
    inventoryUIButton: ecs.eid,
    inventoryUiClosebutton: ecs.eid,
  },
  schemaDefaults: {
    spaceName: 'World Map',
    hideUIOnClick: false,
    hideInventoryOnClick: false,
  },
  data: {
    isLoading: ecs.boolean,
  },
  stateMachine: ({world, eid, schemaAttribute, dataAttribute}) => {
    ecs.defineState('default')
      .initial()
      .onEnter(() => {
        dataAttribute.set(eid, {isLoading: false})
      })
      .listen(eid, ecs.input.UI_CLICK, () => {
        const {hideUIOnClick, hideInventoryOnClick, inventoryUI, inventoryUIButton, inventoryUiClosebutton} = schemaAttribute.get(eid)

        if (hideUIOnClick) {
          window.dispatchEvent(
            new CustomEvent('back-to-map', {detail: {}})
          )
          console.log('[Back to map]: event fired')
        }

        if (hideInventoryOnClick) {
          console.log('disable buttons')
          ecs.Disabled.set(world, inventoryUI)
          ecs.Disabled.remove(world, inventoryUIButton)
          ecs.Disabled.remove(world, inventoryUiClosebutton)
          ecs.Disabled.set(world, eid)
        }
      })
      .listen(eid, ecs.input.UI_RELEASED, () => {
        const {spaceName} = schemaAttribute.get(eid)
        const state = dataAttribute.cursor(eid)
        if (spaceName && !state.isLoading) {
          state.isLoading = true
          console.log('queued space load', spaceName)

          world.time.setTimeout(() => {
            try {
              console.log('loading space', spaceName)
              world.spaces.loadSpace(spaceName)
            } catch (e) {
              console.error('failed to load space', e)
            } finally {
              dataAttribute.set(eid, {isLoading: false})
            }
          }, 1000)
        }
      })
  },
})

Also you should always use world.time to set a timeout instead of using the Javascript native timeout.

Hi,

Thanks for one of the error updates! Did a quick test with the solution provided. However I tried to replaced the entire updated codes from your solution, it seems like it still happening. :cry: For your references:

On the right is the updated codes, and on the left is the error codes.

I know memory leak is another problem, just to mention that it still cause memory leak after that. Thanks for the solution tho! Hopefully we could solve this together. :grinning_face_with_smiling_eyes:

Thanks!