engine_web-ifc: [Bug]: The program exited abnormally while processing the super large model
What happened?
Hi, The program exited abnormally while processing the super large model!
Recently, I encountered an unexpected program exit while working on a model containing 300000 components. The error message is shown in the following figure.
Aborted()
web-ifc-api-node.js:5175
(node:57980) UnhandledPromiseRejectionWarning: RuntimeError: Aborted(). Build with -sASSERTIONS for more info.
at abort (F:\CJXX_WORK\Project\bimrun23dtiles\web-ifc\web-ifc-api-node.js:5179:19)
at _abort (F:\CJXX_WORK\Project\bimrun23dtiles\web-ifc\web-ifc-api-node.js:7139:11)
at <anonymous>:wasm-function[52]:0x16ff
at <anonymous>:wasm-function[345]:0x37baf
at <anonymous>:wasm-function[523]:0x76527
at <anonymous>:wasm-function[127]:0xf9b1
at <anonymous>:wasm-function[879]:0xbdbc4
at <anonymous>:wasm-function[889]:0xbe056
at <anonymous>:wasm-function[213]:0x225b9
at <anonymous>:wasm-function[1325]:0xe21f8
(Use node --trace-warnings ...
to show where the warning was created)
warning.js:43
(node:57980) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict
(see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
warning.js:43
(node:57980) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
For this, I created a simple testing program that only writes simple triangular data. When modelCount=150000, the program cannot execute correctly. When modelCount=100000, the ifc file can be successfully output. It should be noted that program abnormal exit does not only occur during saveFile, but also during WriteLine when the modelCount is large enough (300000) test code: `
const fs = require('fs');
const path = require("path");
const { FILE_DESCRIPTION,Schemas,logical,NewIfcModel, ms,IfcAPI, Handle, IFC4, IFC2X3, IFCBUILDINGSTOREY, IFCPROPERTYSINGLEVALUE, IFCSIUNIT, EMPTY, IFCPROPERTYSET, IFCOWNERHISTORY, IFCRELDEFINESBYPROPERTIES } = require("../web-ifc/web-ifc-api-node.js");
const ifcapi = new IfcAPI();
async function createIFC() {
const filename = "F:\\temp\\ifc\\output\\testexport.ifc"
await ifcapi.Init();
if (!fs.existsSync(filename)) {
if (!fs.existsSync(path.dirname(filename))) {
fs.mkdirSync(path.dirname(filename), {recursive: true});
}
}
const modelOpton = {
schema: Schemas.IFC2X3, // ifc版本
name: "test.ifc",
description: ["1", "2"],
authors: ["3", "4"],
organizations: ["5", "6"],
authorization: "78",
}
const loaderSettings = {}
let modelID = ifcapi.CreateModel(modelOpton, loaderSettings);
const modelCount = 150000;
for (let i = 0; i < modelCount; i++) {
console.log(`${i}/${modelCount}`)
for (let j = 0; j < 50; j++) {
let cartPoint1 = new IFC2X3.IfcCartesianPoint([1,2,3]);
let cartPoint2 = new IFC2X3.IfcCartesianPoint([4,5,6]);
let cartPoint3 = new IFC2X3.IfcCartesianPoint([7,8,9]);
let array = [cartPoint1, cartPoint2, cartPoint3];
let poly = new IFC2X3.IfcPolyLoop(array);
ifcapi.WriteLine(modelID, poly);
}
}
// save file
fs.writeFileSync(filename, ifcapi.SaveModel(modelID));
console.log("ifc exported successfully!")
}
function generatorUUID(){
return Math.random().toString(36).substr(2, 9)+Math.random().toString(36).substr(2, 9)+Math.random().toString(36).substr(2, 4)
}
createIFC()
`
Version
0.0.46
What browsers are you seeing the problem on?
No response
Relevant log output
No response
Anything else?
No response
About this issue
- Original URL
- State: open
- Created 6 months ago
- Comments: 37
Yes that is a bug you have uncovered. I will take a look hopefully today
Let me look into this - the memory should be being cleared
So this should now be fixed. I also added a method to write files out using a callback, which makes it a lot quicker in the case of huge files (see the WebIfcApi.spec.ts test lines 536 as an example)
This is quite a lot more tricky that we thought. Essentially, it seems like you are overfilling the WASM memory so we need to write the data out when that happens.
I am hoping in the next week.
Sent from Outlook for Androidhttps://aka.ms/AAb9ysg
From: Zhouhai @.> Sent: Friday, January 5, 2024 3:08:58 AM To: IFCjs/web-ifc @.> Cc: Thomas Beach @.>; Mention @.> Subject: Re: [IFCjs/web-ifc] [Bug]: The program exited abnormally while processing the super large model (Issue #538)
External email to Cardiff University - Take care when replying/opening attachments or links. Nid ebost mewnol o Brifysgol Caerdydd yw hwn - Cymerwch ofal wrth ateb/agor atodiadau neu ddolenni.
@beachtomhttps://github.com/beachtom I am glad that the cause of the problem has been identified. Is there an expected timeline? This is important to me. Unfortunately, I am not a C++programmer, otherwise I could have made some contributions. thanks
— Reply to this email directly, view it on GitHubhttps://github.com/IFCjs/web-ifc/issues/538#issuecomment-1878062442, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AGIIJHVAO5CG5DP3JFLFLQLYM5VEVAVCNFSM6AAAAABBCNWVDSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNZYGA3DENBUGI. You are receiving this because you were mentioned.Message ID: @.***>