itwinjs-core icon indicating copy to clipboard operation
itwinjs-core copied to clipboard

iModel viewer shows nothing but point clouds (4.6 to 4.7)

Open lijiayi0921 opened this issue 1 year ago • 14 comments

Hi,

My iModel view does not load the 3D model. It loads the point clouds correctly.

No error from console. Scopes are : imodelaccess:read imodels:read itwinjs (I tried itwin-platform but the same)

This happens since I moved from 4.6 to 4.7 (although many other issues are solved thanks to the help from this forum) I'm using the packages from the latest "npx create-react-app .... --template @itwin/web-viewer " : (Which might not be the latest for every package)

"@itwin/appui-abstract": "^4.7.5",
    "@itwin/appui-layout-react": "^4.8.3",
    "@itwin/appui-react": "^4.15.2",
    "@itwin/browser-authorization": "^1.1.2",
    "@itwin/components-react": "^4.15.2",
    "@itwin/core-bentley": "^4.7.5",
    "@itwin/core-common": "^4.7.5",
    "@itwin/core-frontend": "^4.7.5",
    "@itwin/core-geometry": "^4.7.5",
    "@itwin/core-i18n": "^4.7.5",
    "@itwin/core-markup": "^4.7.5",
    "@itwin/core-orbitgt": "^4.7.5",
    "@itwin/core-quantity": "^4.7.5",
    "@itwin/core-react": "^4.15.2",
    "@itwin/core-telemetry": "^4.7.5",
    "@itwin/ecschema-metadata": "^4.7.5",
    "@itwin/imodel-browser-react": "^1.3.1",
    "@itwin/imodel-components-react": "^4.15.2",
    "@itwin/imodels-access-frontend": "^4.1.6",
    "@itwin/itwinui-react": "^2.12.26",
    "@itwin/measure-tools-react": "^0.13.0",
    "@itwin/presentation-common": "^4.7.5",
    "@itwin/presentation-components": "^4.4.1",
    "@itwin/presentation-frontend": "^4.7.5",
    "@itwin/property-grid-react": "^1.10.0",
    "@itwin/tree-widget-react": "^1.2.2",
    "@itwin/web-viewer-react": "^4.2.5",
    "@itwin/webgl-compatibility": "^4.7.5",

In the Tree View everything is shown. Any idea why this happens ?

Thank you Jiayi

lijiayi0921 avatar Jul 11 '24 20:07 lijiayi0921

If you open the network tab in the dev tools, are there any requests that fail in 4.7 that wasn't in 4.6?

hl662 avatar Jul 11 '24 20:07 hl662

Nothing fails in Network tab. Btw in order to have a working version of iTwin, I took the same implementation from the simple example from : "npx create-react-app .... --template @itwin/web-viewer " The simple viewer loads the model correctly. But my implementation does not - even if I change every property of Viewer to be the same.

   <Viewer
                iTwinId={props.file?.platformBucket}
                iModelId={props.file?.platformModel}
                authClient={authClient}
                viewCreatorOptions={viewCreatorOptions}
                enablePerformanceMonitors={process.env.MODE === 'DEBUG'}
                onIModelAppInit={onIModelAppInit}
                // onIModelConnected={onIModelConnected}
                // additionalI18nNamespaces={['safe', 'safeTools']}
                uiProviders={[
                    new ViewerNavigationToolsProvider(),
                    new ViewerContentToolsProvider({
                        vertical: {
                            measureGroup: false,
                        },
                    }),
                    new ViewerStatusbarItemsProvider(),
                    new TreeWidgetUiItemsProvider(),
                    new PropertyGridUiItemsProvider({
                        propertyGridProps: {
                            autoExpandChildCategories: true,
                            ancestorsNavigationControls: (props) => (
                                <AncestorsNavigationControls {...props} />
                            ),
                            contextMenuItems: [
                                (props) => <CopyPropertyTextContextMenuItem {...props} />,
                            ],
                            settingsMenuItems: [
                                (props) => (
                                    <ShowHideNullValuesSettingsMenuItem
                                        {...props}
                                        persist={true}
                                    />
                                ),
                            ],
                        },
                    }),
                    new MeasureToolsUiItemsProvider(),
                    ...(safeExt?.uiProviders ?? [])
                ]}
            />

lijiayi0921 avatar Jul 11 '24 21:07 lijiayi0921

Is the simple example from npx create-react-app also using 4.7 packages? And that is loading the model correctly?

hl662 avatar Jul 12 '24 14:07 hl662

Hi @hl662, thank you so much for following my issue. Yes the sample works correctly (package list as in my original post)

Comparing the network traffic, both seem to load the 3d model :

Sample viewer : image

My app image

I was comparing the resulting css in the navigator, didn't find anything significant yet. Could that be the issue ?

lijiayi0921 avatar Jul 12 '24 15:07 lijiayi0921

I can't see CSS being the cause... if the tree on the side is shown, and you're able to see some stuff rendered on the page, and within the viewport... I'm surprised that there aren't any errors in the console?

hl662 avatar Jul 12 '24 15:07 hl662

The only error is this (yet not everytime) : Root font size must not be overridden. See https://github.com/iTwin/iTwinUI/wiki/iTwinUI-react-v2-migration-guide#relative-font-size There are warnings related to deprecated UI component as well.

It happens on localhost or deployed, with Chrome and with FF... Is there some viewer settings that could be the cause ?

lijiayi0921 avatar Jul 12 '24 16:07 lijiayi0921

It's not too clear what the root cause is yet... I see from your package.json that you jumped straight to 4.7.5. Could you downgrade that to 4.7.0? Let's see if we could nail down which version of 4.7 is causing this problem, and compare that against the release change logs.

hl662 avatar Jul 12 '24 16:07 hl662

Going back to 4.6.2 (for all packages that are at 4.7.5), problem solved, the model reappears. I'll try to go up again to see where it brreaks

lijiayi0921 avatar Jul 12 '24 17:07 lijiayi0921

At 4.7.0 the model is not showing

lijiayi0921 avatar Jul 12 '24 17:07 lijiayi0921

In the network tab, can you filter for these following requests that start with api.bentley.com/imodel/rpc/v4? If any are failing, please provide the x-correlation-id header value of those errors, so we can check on our side

hl662 avatar Jul 12 '24 17:07 hl662

There were no request that were failing...

lijiayi0921 avatar Jul 12 '24 17:07 lijiayi0921

if you were to compare the network requests and the waterfall between the sample viewer and your implementation of the viewer, are there discrepancies in the flow? Maybe some requests in one app weren't executed?

hl662 avatar Jul 12 '24 17:07 hl662

Yes in my app there are some more requests (redundant ?).

Here they are filtered with "api.bentley.com/imodel/rpc/v4"

My app :

               
IModelReadRpcInterface-3.6.0-getConnectionProps?pa…mMmJmYWZmNjQ0N2ZmNTE3YzlmMzMwOGUyZjdlIn19XQ%3D%3D 200 h2 api.bentley.com fetch WebAppRpcRequest.ts:200 1.0 kB 137 ms
IModelReadRpcInterface-3.6.0-getConnectionProps?pa…mMmJmYWZmNjQ0N2ZmNTE3YzlmMzMwOGUyZjdlIn19XQ%3D%3D 200 h2 api.bentley.com fetch WebAppRpcRequest.ts:200 0 B 113 ms
PresentationRpcInterface-4.1.0-getSelectionScopes 200 h2 api.bentley.com fetch WebAppRpcRequest.ts:200 498 B 45 ms
PresentationRpcInterface-4.1.0-getSelectionScopes 200 h2 api.bentley.com fetch WebAppRpcRequest.ts:200 239 B 81 ms
IModelReadRpcInterface-3.6.0-getCustomViewState3dD…0N2ZmNTE3YzlmMzMwOGUyZjdlIiwiaW5kZXgiOjEwfX0se31d 200 h2 api.bentley.com fetch WebAppRpcRequest.ts:200 (disk cache) 1 ms
IModelReadRpcInterface-3.6.0-hydrateViewState?para…GVjdG9yU3RhdGVNb2RlbHMiOiIrMjAwMDAwMDAwMEMifV0%3D 200 h2 api.bentley.com fetch WebAppRpcRequest.ts:200 (disk cache) 1 ms
IModelReadRpcInterface-3.6.0-querySubCategories?pa…rMUUrNDIrMyoyKzExKzEyKzE5KzUxNyszNDgrM0YrQytFNiJd 200 h2 api.bentley.com fetch WebAppRpcRequest.ts:200 (disk cache) 1 ms
IModelTileRpcInterface-3.2.0-requestTileTreeProps?…XgiOjEwfX0sIjIyXzFkLUU6MF8weDIwMDAwMDAwMDBjIl0%3D 200 h2 api.bentley.com fetch WebAppRpcRequest.ts:200 (disk cache) 4 ms
IModelReadRpcInterface-3.6.0-queryModelProps 200 h2 api.bentley.com fetch WebAppRpcRequest.ts:200 490 B 42 ms
PresentationRpcInterface-4.1.0-getPagedNodes 200 h2 api.bentley.com fetch index.ts:102 535 B 325 ms
PresentationRpcInterface-4.1.0-getPagedNodes 200 h2 api.bentley.com fetch index.ts:102 502 B 322 ms
IModelTileRpcInterface-3.2.0-getTileCacheConfig 200 h2 api.bentley.com fetch WebAppRpcRequest.ts:200 333 B 42 ms
PresentationRpcInterface-4.1.0-getPagedNodes 200 h2 api.bentley.com fetch index.ts:102 533 B 137 ms
PresentationRpcInterface-4.1.0-getPagedNodes 200 h2 api.bentley.com fetch index.ts:102 567 B 81 ms
IModelReadRpcInterface-3.6.0-queryRows 200 h2 api.bentley.com fetch WebAppRpcRequest.ts:200 421 B 30 ms
IModelReadRpcInterface-3.6.0-queryRows 200 h2 api.bentley.com fetch WebAppRpcRequest.ts:200 408 B 37 ms

Sample viewer :

               
IModelReadRpcInterface-3.6.0-getConnectionProps?pa…mMmJmYWZmNjQ0N2ZmNTE3YzlmMzMwOGUyZjdlIn19XQ%3D%3D 200 h2 api.bentley.com fetch WebAppRpcRequest.ts:200 1.1 kB 68 ms
PresentationRpcInterface-4.1.0-getSelectionScopes 200 h2 api.bentley.com fetch WebAppRpcRequest.ts:200 452 B 31 ms
IModelReadRpcInterface-3.6.0-getCustomViewState3dD…0N2ZmNTE3YzlmMzMwOGUyZjdlIiwiaW5kZXgiOjEwfX0se31d 200 h2 api.bentley.com fetch WebAppRpcRequest.ts:200 (disk cache) 2 ms
IModelReadRpcInterface-3.6.0-hydrateViewState?para…GVjdG9yU3RhdGVNb2RlbHMiOiIrMjAwMDAwMDAwMEMifV0%3D 200 h2 api.bentley.com fetch WebAppRpcRequest.ts:200 (disk cache) 1 ms
IModelReadRpcInterface-3.6.0-querySubCategories?pa…rMUUrNDIrMyoyKzExKzEyKzE5KzUxNyszNDgrM0YrQytFNiJd 200 h2 api.bentley.com fetch WebAppRpcRequest.ts:200 (disk cache) 1 ms
IModelReadRpcInterface-3.6.0-queryModelProps 200 h2 api.bentley.com fetch WebAppRpcRequest.ts:200 465 B 31 ms
PresentationRpcInterface-4.1.0-getPagedNodes 200 h2 api.bentley.com fetch index.ts:102 537 B 260 ms
IModelTileRpcInterface-3.2.0-requestTileTreeProps?…XgiOjEwfX0sIjIyXzFkLUU6MF8weDIwMDAwMDAwMDBjIl0%3D 200 h2 api.bentley.com fetch WebAppRpcRequest.ts:200 (disk cache) 1 ms
IModelTileRpcInterface-3.2.0-getTileCacheConfig 200 h2 api.bentley.com fetch WebAppRpcRequest.ts:200 333 B 31 ms
PresentationRpcInterface-4.1.0-getPagedNodes 200 h2 api.bentley.com fetch index.ts:102 567 B 721 ms
IModelReadRpcInterface-3.6.0-queryRows 200 h2 api.bentley.com fetch WebAppRpcRequest.ts:200 450 B 31 ms
IModelReadRpcInterface-3.6.0-queryRows 200 h2 api.bentley.com fetch WebAppRpcRequest.ts:200 367 B 39 ms

lijiayi0921 avatar Jul 12 '24 18:07 lijiayi0921

I'm curious, maybe the redundant requests are coming from a mismanagement of react lifecycle? Maybe the inititalization is being triggered twice (although it might be running twice because of react's StrictMode causing 2 renders every time). You can also compare your implementation of the viewer against the one in the sample app (including the react component that houses the viewer), and not just the same parameters being passed into both implementations

hl662 avatar Jul 15 '24 16:07 hl662

Hi @hl662 I recently solved issue. The reason was that I manually copied the public folders as suggest by this issue : https://github.com/iTwin/itwinjs-core/issues/6763

When I upgraded iTwin again I had an outdated parse-imdl-worker.js, which did not function well but did not send any error neither.

I added a postintall script which copies everything needed from itwin packages to the corresponding path (mine is /viewer/itwin) in my public folder. The problem is hopefully solved for good.

try {
    console.log('Copying iTwin public files...');
    const itwinPublicDst = './public/viewer/itwin';
    if (fs.existsSync(itwinPublicDst)) {
        fs.rmSync(itwinPublicDst, { recursive: true, force: true });
        console.log(`Cleared: ${itwinPublicDst}`);
        fs.mkdirSync(itwinPublicDst, { recursive: true });
    }

    const itwinParentSrc = './node_modules/@itwin';
    fs.readdirSync(itwinParentSrc).forEach(module => {
        const modulePublic = `${itwinParentSrc}/${module}/lib/public`;
        if (fs.existsSync(modulePublic) && fs.statSync(modulePublic).isDirectory()) {
            fs.cpSync(modulePublic, itwinPublicDst, { recursive: true });
            console.log(`Copied: @itwin/${module}`);
        }
    });
} catch (error) {
    console.error('Error:', error.message);
}

Thank you Jiayi

lijiayi0921 avatar Apr 03 '25 13:04 lijiayi0921