Skip to content

[Bug]: "memory access out of bounds" during ifc to frag conversion #1774

@alexberd

Description

@alexberd

What happened?

I am using the following npm script to convert .ifc to .frag and I am getting the following error when trying convert the ifc of the following element exported from Revit. I am wondering what the error is for the particular elements and if there is any flag to disregard elements which cannot be converted from ifc

web-ifc version wasm file:

https://app.unpkg.com/web-ifc@0.0.74/files/web-ifc-node.wasm

npm error:

RuntimeError: memory access out of bounds
    at wasm://wasm/00505fe2:wasm-function[209]:0x19347
    at wasm://wasm/00505fe2:wasm-function[209]:0x1f112
    at wasm://wasm/00505fe2:wasm-function[209]:0x1f112
    at wasm://wasm/00505fe2:wasm-function[209]:0x1f112
    at wasm://wasm/00505fe2:wasm-function[209]:0x1f112
    at wasm://wasm/00505fe2:wasm-function[209]:0x1f112
    at wasm://wasm/00505fe2:wasm-function[209]:0x1f112
    at wasm://wasm/00505fe2:wasm-function[209]:0x1f112
    at wasm://wasm/00505fe2:wasm-function[209]:0x1f112
    at wasm://wasm/00505fe2:wasm-function[209]:0x1f112

element visual geometry:
Image

ifc file:
https://we.tl/t-9xSQVEEbXZ

npm script:

import fs from "node:fs/promises";
import path from "node:path";
import process from "node:process";
import * as FRAGS from "@thatopen/fragments";

async function main() {
  const [inputIfc, outputFrag] = process.argv.slice(2);

  if (!inputIfc || !outputFrag) {
    console.log("Usage: node convert-ifc-to-frag.mjs input.ifc output.frag");
    process.exit(1);
  }

  const ifcBytes = new Uint8Array(await fs.readFile(inputIfc));

  const importer = new FRAGS.IfcImporter();
 
  const wasmDir = path.resolve("public", "web-ifc-074") + path.sep;
  importer.wasm = { absolute: true, path: wasmDir };

  console.log(`Converting: ${path.basename(inputIfc)} (${(ifcBytes.byteLength / 1024 / 1024).toFixed(1)} MB)`);
  
  const fragBuffer = await importer.process({
    bytes: ifcBytes,
    progressCallback: (progress) => {
      // progress is typically 0..1
      const pct = Math.round(progress * 100);
      process.stdout.write(`\rProgress: ${pct}%   `);
    },
  });

  process.stdout.write("\n");
  await fs.writeFile(outputFrag, Buffer.from(new Uint8Array(fragBuffer)));

  console.log(`Saved: ${outputFrag}`);
}

main().catch((e) => {
  console.error(e);
  process.exit(1);
});

FOR THE ABOVE SCRIPT TO WORK I HAVE PLACED web-ifc-node.wasm AT THE FOLLOWING PATH:
MYPROJECT\public\web-ifc-074\web-ifc-node.wasm

Version

0.0.72 & 0.0.74

What browsers are you seeing the problem on?

No response

Relevant log output

RuntimeError: memory access out of bounds
    at wasm://wasm/00505fe2:wasm-function[209]:0x19347
    at wasm://wasm/00505fe2:wasm-function[209]:0x1f112
    at wasm://wasm/00505fe2:wasm-function[209]:0x1f112
    at wasm://wasm/00505fe2:wasm-function[209]:0x1f112
    at wasm://wasm/00505fe2:wasm-function[209]:0x1f112
    at wasm://wasm/00505fe2:wasm-function[209]:0x1f112
    at wasm://wasm/00505fe2:wasm-function[209]:0x1f112
    at wasm://wasm/00505fe2:wasm-function[209]:0x1f112
    at wasm://wasm/00505fe2:wasm-function[209]:0x1f112
    at wasm://wasm/00505fe2:wasm-function[209]:0x1f112

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    wontfixThis will not be worked on

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions