AFASSoftware / maquette

Pure and simple virtual DOM library

Home Page:https://maquettejs.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Object not found when text changes.

overeemm opened this issue · comments

NotFoundError: The object can not be found here.
stack:
├ insertBefore()
│ └ [native code]:undefined
├ updateDom()
│ └ webpack://afasPodium/node_modules/maquette/dist/maquette.umd.js:461
├ Object.keys()
│ └ webpack://afasPodium/node_modules/maquette/dist/maquette.umd.js:311
├ Object.keys()
│ └ webpack://afasPodium/node_modules/maquette/dist/maquette.umd.js:321
├ append()
│ └ webpack://afasPodium/node_modules/maquette/dist/maquette.umd.js:545

This probably happens in
domNode.ownerDocument.createTextNode(vnode.text);
probably when the text changes to null.

We have tried hard to reproduce this problem, no success thusfar. If anyone can reproduce this issue, we will investigate this further.

We seem to have found another such crash in our logs in the wild:

NotFoundError: The object can not be found here.
stack:
├ insertBefore()
│ └ [native code]:undefined
├ domNode()
│ └ webpack://afasPodium/node_modules/maquette/dist/maquette.umd.js:268
├ same()
│ └ webpack://afasPodium/node_modules/maquette/dist/maquette.umd.js:436
├ vnode.vnodeSelector.lastIndexOf()
│ └ webpack://afasPodium/node_modules/maquette/dist/maquette.umd.js:483
├ update()
│ └ webpack://afasPodium/node_modules/maquette/dist/maquette.umd.js:503
└ rendersi
└ /podium/services/projector.ts:142

Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.3 Safari/605.1.15

Some observations:

We have not been able to find a way how insertBefore crashes in safari could occur while chrome does not crash at all.
Expriments at: https://typescript-hualof.stackblitz.io

The stacktrace translated to the typescript code is as follows:
insertBefore() (native)
createDom() projection.ts:281
updateChildren() projection.ts:454
updateDom() projection.ts:500
update() projection.ts:524

According to the stacktrace, the crash occurs when adding a new child directly to the root of the projection. This child is not the last child.

We have strong suspicion that the error is not in maquette, but in our app. There are lots of animations and afterCreate calls that do things with DOMElements, we suspect that some of this code is removing a DOMNode that maquette still has a reference to.
Experiments at https://stackblitz.com/edit/maquette-notfound-investigation show that only if a DOMNode is removed from outside of maquette, that this symptom occurs.

We found out that the problem is not iOS specific, we now also see similar issues on chrome. This makes it even more probable that the bug is in our code, not maquette.