Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

TokamakDemo breaks after use of _domRef #326

Closed
MaxDesiatov opened this issue Dec 6, 2020 · 0 comments · Fixed by #407
Closed

TokamakDemo breaks after use of _domRef #326

MaxDesiatov opened this issue Dec 6, 2020 · 0 comments · Fixed by #407
Labels
bug Something isn't working

Comments

@MaxDesiatov
Copy link
Collaborator

MaxDesiatov commented Dec 6, 2020

Steps to reproduce:

  1. Navigate to the "DOM reference" screen.
  2. Press the "Click me" button.
  3. Navigate to any other screen.

All screens stop working after "Click me" button is pressed. Reproducible in Chrome, Firefox, and Safari for me.

Stack trace:

  wasmFs.fs.writeSync at ./entrypoint/dev.js?:52:25
  a/this.wasiImport.fd_write</< at ./node_modules/@wasmer/wasi/lib/index.esm.js?:115:429
  a/this.wasiImport.fd_write< at ./node_modules/@wasmer/wasi/lib/index.esm.js?:115:372
  Z/< at ./node_modules/@wasmer/wasi/lib/index.esm.js?:102:271
  write at wasm-function[81806]:0x17da690
  swift_reportError at wasm-function[41398]:0x8a757e
  _swift_stdlib_reportFatalErrorInFile at wasm-function[42694]:0x90dcd2
  closure #1 (UnsafeBufferPointer<UInt8>) -> () in closure #1 (UnsafeBufferPointer<UInt8>) -> () in _assertionFailure(_: StaticString, _: String, file: StaticString, line: UInt, flags: UInt32) -> Never at wasm-function[23388]:0x602c84
  function signature specialization <Arg[1] = [Closure Propagated : closure #1 (UnsafeBufferPointer<UInt8>) -> () in closure #1 (UnsafeBufferPointer<UInt8>) -> () in _assertionFailure(_: StaticString, _: String, file: StaticString, line: UInt, flags: UInt32) -> Never, Argument Types : [Swift.StaticStringSwift.UnsafeBufferPointer<UInt8>Swift.UIntSwift.UInt32]> of generic specialization <()> of String.withUTF8<A>((UnsafeBufferPointer<UInt8>) throws -> A) throws -> A at wasm-function[23369]:0x601fda
  Swift._assertionFailure(_: StaticString, _: String, file: StaticString, line: UInt, flags: UInt32) -> Never at wasm-function[22528]:0x5d472c
  swift_unexpectedError at wasm-function[24962]:0x663194
  JavaScriptKit.JSFunction.callAsFunction(this: Optional<JavaScriptKit.JSObject>, arguments: Array<JavaScriptKit.ConvertibleToJSValue>) -> JavaScriptKit.JSValue at wasm-function[730]:0x59100
  closure #1 (JavaScriptKit.ConvertibleToJSValue...) -> JavaScriptKit.JSValue in JavaScriptKit.JSObject.subscript.getter : (String) -> Optional<(JavaScriptKit.ConvertibleToJSValue...) -> JavaScriptKit.JSValue> at wasm-function[869]:0x6302d
  partial apply forwarder for closure #1 (JavaScriptKit.ConvertibleToJSValue...) -> JavaScriptKit.JSValue in JavaScriptKit.JSObject.subscript.getter : (String) -> Optional<(JavaScriptKit.ConvertibleToJSValue...) -> JavaScriptKit.JSValue> at wasm-function[868]:0x62f6b
  TokamakDOM.DOMRenderer.unmount(target: TokamakDOM.DOMNode, from: TokamakDOM.DOMNode, with: TokamakCore.MountedHostView<TokamakDOM.DOMRenderer>, completion: () -> ()) -> () at wasm-function[17435]:0x42a63c
  protocol witness for TokamakCore.Renderer.unmount(target: A.TargetType, from: A.TargetType, with: TokamakCore.MountedHostView<A>, completion: () -> ()) -> () in conformance TokamakDOM.DOMRenderer : TokamakCore.Renderer in TokamakDOM at wasm-function[17445]:0x42a9bc
  TokamakCore.MountedHostView.unmount(with: TokamakCore.StackReconciler<A>) -> () at wasm-function[11815]:0x2eafc1
  closure #1 (TokamakCore.MountedElement<A>) -> () in closure #1 () -> () in TokamakCore.MountedHostView.unmount(with: TokamakCore.StackReconciler<A>) -> () at wasm-function[11821]:0x2eb36e
  partial apply forwarder for closure #1 (TokamakCore.MountedElement<A>) -> () in closure #1 () -> () in TokamakCore.MountedHostView.unmount(with: TokamakCore.StackReconciler<A>) -> () at wasm-function[11818]:0x2eb235
  reabstraction thunk helper <A where A: TokamakCore.Renderer> from @callee_guaranteed (@guaranteed TokamakCore.MountedElement<A>) -> (@error @owned Error) to @escaping @callee_guaranteed (@in_guaranteed TokamakCore.MountedElement<A>) -> (@error @owned Error) at wasm-function[11424]:0x2d0a10
  reabstraction thunk helper <A where A: TokamakCore.Renderer> from @callee_guaranteed (@guaranteed TokamakCore.MountedElement<A>) -> (@error @owned Error) to @escaping @callee_guaranteed (@in_guaranteed TokamakCore.MountedElement<A>) -> (@error @owned Error)partial apply forwarder with unmangled suffix ".29" at wasm-function[11819]:0x2eb28d
  (extension in Swift):Swift.Sequence.forEach((A.Element) throws -> ()) throws -> () at wasm-function[25595]:0x68b358
  closure #1 () -> () in TokamakCore.MountedHostView.unmount(with: TokamakCore.StackReconciler<A>) -> () at wasm-function[11817]:0x2eb1ad
  partial apply forwarder for closure #1 () -> () in TokamakCore.MountedHostView.unmount(with: TokamakCore.StackReconciler<A>) -> () at wasm-function[11816]:0x2eb021
  $defer #1 () -> () in TokamakDOM.DOMRenderer.unmount(target: TokamakDOM.DOMNode, from: TokamakDOM.DOMNode, with: TokamakCore.MountedHostView<TokamakDOM.DOMRenderer>, completion: () -> ()) -> () at wasm-function[17438]:0x42a832
  TokamakDOM.DOMRenderer.unmount(target: TokamakDOM.DOMNode, from: TokamakDOM.DOMNode, with: TokamakCore.MountedHostView<TokamakDOM.DOMRenderer>, completion: () -> ()) -> () at wasm-function[17435]:0x42a68e
  protocol witness for TokamakCore.Renderer.unmount(target: A.TargetType, from: A.TargetType, with: TokamakCore.MountedHostView<A>, completion: () -> ()) -> () in conformance TokamakDOM.DOMRenderer : TokamakCore.Renderer in TokamakDOM at wasm-function[17445]:0x42a9bc
  TokamakCore.MountedHostView.unmount(with: TokamakCore.StackReconciler<A>) -> () at wasm-function[11815]:0x2eafc1
  closure #1 (TokamakCore.MountedElement<A>) -> () in TokamakCore.MountedCompositeView.unmount(with: TokamakCore.StackReconciler<A>) -> () at wasm-function[11566]:0x2db5be
  partial apply forwarder for closure #1 (TokamakCore.MountedElement<A>) -> () in TokamakCore.MountedCompositeView.unmount(with: TokamakCore.StackReconciler<A>) -> () at wasm-function[11563]:0x2db4a6
  reabstraction thunk helper <A where A: TokamakCore.Renderer> from @callee_guaranteed (@guaranteed TokamakCore.MountedElement<A>) -> (@error @owned Error) to @escaping @callee_guaranteed (@in_guaranteed TokamakCore.MountedElement<A>) -> (@error @owned Error) at wasm-function[11424]:0x2d0a10
  partial apply forwarder for reabstraction thunk helper <A where A: TokamakCore.Renderer> from @callee_guaranteed (@guaranteed TokamakCore.MountedElement<A>) -> (@error @owned Error) to @escaping @callee_guaranteed (@in_guaranteed TokamakCore.MountedElement<A>) -> (@error @owned Error) at wasm-function[11564]:0x2db4fe
  (extension in Swift):Swift.Sequence.forEach((A.Element) throws -> ()) throws -> () at wasm-function[25595]:0x68b358
  TokamakCore.MountedCompositeView.unmount(with: TokamakCore.StackReconciler<A>) -> () at wasm-function[11562]:0x2db171
  closure #1 (TokamakCore.MountedElement<A>) -> () in TokamakCore.MountedCompositeView.unmount(with: TokamakCore.StackReconciler<A>) -> () at wasm-function[11566]:0x2db5be
  partial apply forwarder for closure #1 (TokamakCore.MountedElement<A>) -> () in TokamakCore.MountedCompositeView.unmount(with: TokamakCore.StackReconciler<A>) -> () at wasm-function[11563]:0x2db4a6
  reabstraction thunk helper <A where A: TokamakCore.Renderer> from @callee_guaranteed (@guaranteed TokamakCore.MountedElement<A>) -> (@error @owned Error) to @escaping @callee_guaranteed (@in_guaranteed TokamakCore.MountedElement<A>) -> (@error @owned Error) at wasm-function[11424]:0x2d0a10
  partial apply forwarder for reabstraction thunk helper <A where A: TokamakCore.Renderer> from @callee_guaranteed (@guaranteed TokamakCore.MountedElement<A>) -> (@error @owned Error) to @escaping @callee_guaranteed (@in_guaranteed TokamakCore.MountedElement<A>) -> (@error @owned Error) at wasm-function[11564]:0x2db4fe
  (extension in Swift):Swift.Sequence.forEach((A.Element) throws -> ()) throws -> () at wasm-function[25595]:0x68b358
  TokamakCore.MountedCompositeView.unmount(with: TokamakCore.StackReconciler<A>) -> () at wasm-function[11562]:0x2db171
  closure #1 (TokamakCore.MountedElement<A>) -> () in TokamakCore.MountedCompositeView.unmount(with: TokamakCore.StackReconciler<A>) -> () at wasm-function[11566]:0x2db5be
  partial apply forwarder for closure #1 (TokamakCore.MountedElement<A>) -> () in TokamakCore.MountedCompositeView.unmount(with: TokamakCore.StackReconciler<A>) -> () at wasm-function[11563]:0x2db4a6
  reabstraction thunk helper <A where A: TokamakCore.Renderer> from @callee_guaranteed (@guaranteed TokamakCore.MountedElement<A>) -> (@error @owned Error) to @escaping @callee_guaranteed (@in_guaranteed TokamakCore.MountedElement<A>) -> (@error @owned Error) at wasm-function[11424]:0x2d0a10
  partial apply forwarder for reabstraction thunk helper <A where A: TokamakCore.Renderer> from @callee_guaranteed (@guaranteed TokamakCore.MountedElement<A>) -> (@error @owned Error) to @escaping @callee_guaranteed (@in_guaranteed TokamakCore.MountedElement<A>) -> (@error @owned Error) at wasm-function[11564]:0x2db4fe
  (extension in Swift):Swift.Sequence.forEach((A.Element) throws -> ()) throws -> () at wasm-function[25595]:0x68b358
  TokamakCore.MountedCompositeView.unmount(with: TokamakCore.StackReconciler<A>) -> () at wasm-function[11562]:0x2db171
  closure #1 (TokamakCore.MountedElement<A>) -> () in TokamakCore.MountedCompositeView.unmount(with: TokamakCore.StackReconciler<A>) -> () at wasm-function[11566]:0x2db5be
  partial apply forwarder for closure #1 (TokamakCore.MountedElement<A>) -> () in TokamakCore.MountedCompositeView.unmount(with: TokamakCore.StackReconciler<A>) -> () at wasm-function[11563]:0x2db4a6
  reabstraction thunk helper <A where A: TokamakCore.Renderer> from @callee_guaranteed (@guaranteed TokamakCore.MountedElement<A>) -> (@error @owned Error) to @escaping @callee_guaranteed (@in_guaranteed TokamakCore.MountedElement<A>) -> (@error @owned Error) at wasm-function[11424]:0x2d0a10
  partial apply forwarder for reabstraction thunk helper <A where A: TokamakCore.Renderer> from @callee_guaranteed (@guaranteed TokamakCore.MountedElement<A>) -> (@error @owned Error) to @escaping @callee_guaranteed (@in_guaranteed TokamakCore.MountedElement<A>) -> (@error @owned Error) at wasm-function[11564]:0x2db4fe
  (extension in Swift):Swift.Sequence.forEach((A.Element) throws -> ()) throws -> () at wasm-function[25595]:0x68b358
  TokamakCore.MountedCompositeView.unmount(with: TokamakCore.StackReconciler<A>) -> () at wasm-function[11562]:0x2db171
  closure #1 (TokamakCore.MountedElement<A>) -> () in TokamakCore.MountedCompositeView.unmount(with: TokamakCore.StackReconciler<A>) -> () at wasm-function[11566]:0x2db5be
  partial apply forwarder for closure #1 (TokamakCore.MountedElement<A>) -> () in TokamakCore.MountedCompositeView.unmount(with: TokamakCore.StackReconciler<A>) -> () at wasm-function[11563]:0x2db4a6
  reabstraction thunk helper <A where A: TokamakCore.Renderer> from @callee_guaranteed (@guaranteed TokamakCore.MountedElement<A>) -> (@error @owned Error) to @escaping @callee_guaranteed (@in_guaranteed TokamakCore.MountedElement<A>) -> (@error @owned Error) at wasm-function[11424]:0x2d0a10
  partial apply forwarder for reabstraction thunk helper <A where A: TokamakCore.Renderer> from @callee_guaranteed (@guaranteed TokamakCore.MountedElement<A>) -> (@error @owned Error) to @escaping @callee_guaranteed (@in_guaranteed TokamakCore.MountedElement<A>) -> (@error @owned Error) at wasm-function[11564]:0x2db4fe
  (extension in Swift):Swift.Sequence.forEach((A.Element) throws -> ()) throws -> () at wasm-function[25595]:0x68b358
  TokamakCore.MountedCompositeView.unmount(with: TokamakCore.StackReconciler<A>) -> () at wasm-function[11562]:0x2db171
  TokamakCore.StackReconciler.reconcile<A>(_: TokamakCore.MountedCompositeElement<A>, with: A1, getElementType: (A1) -> Any.Type, updateChild: (TokamakCore.MountedElement<A>) -> (), mountChild: (A1) -> TokamakCore.MountedElement<A>) -> () at wasm-function[13020]:0x331ed4
  TokamakCore.MountedCompositeView.update(with: TokamakCore.StackReconciler<A>) -> () at wasm-function[11568]:0x2db7d7
  TokamakCore.MountedHostView.update(with: TokamakCore.StackReconciler<A>) -> () at wasm-function[11822]:0x2ec234
  TokamakCore.MountedHostView.update(with: TokamakCore.StackReconciler<A>) -> () at wasm-function[11822]:0x2ec234
  TokamakCore.MountedHostView.update(with: TokamakCore.StackReconciler<A>) -> () at wasm-function[11822]:0x2ec234
  TokamakCore.StackReconciler.reconcile<A>(_: TokamakCore.MountedCompositeElement<A>, with: A1, getElementType: (A1) -> Any.Type, updateChild: (TokamakCore.MountedElement<A>) -> (), mountChild: (A1) -> TokamakCore.MountedElement<A>) -> () at wasm-function[13020]:0x331eae
  TokamakCore.MountedCompositeView.update(with: TokamakCore.StackReconciler<A>) -> () at wasm-function[11568]:0x2db7d7
  TokamakCore.StackReconciler.(updateStateAndReconcile in _FCAA3CDB23B668BF64A31B25B678943F)() -> () at wasm-function[12928]:0x32cecc
  closure #1 () -> () in TokamakCore.StackReconciler.queueUpdate(for: TokamakCore.MountedCompositeElement<A>) -> () at wasm-function[12925]:0x32cc15
  partial apply forwarder for closure #1 () -> () in TokamakCore.StackReconciler.queueUpdate(for: TokamakCore.MountedCompositeElement<A>) -> () at wasm-function[12923]:0x32ca9b
  closure #1 () -> () in OpenCombineJS.JSScheduler.schedule(options: Optional<OpenCombineJS.JSScheduler.SchedulerOptions>, _: () -> ()) -> () at wasm-function[8484]:0x25af61
  partial apply forwarder for closure #1 () -> () in OpenCombineJS.JSScheduler.schedule(options: Optional<OpenCombineJS.JSScheduler.SchedulerOptions>, _: () -> ()) -> () at wasm-function[8479]:0x25ad7a
  closure #1 (Array<JavaScriptKit.JSValue>) -> () in JavaScriptKit.JSTimer.init(millisecondsDelay: Double, isRepeating: Bool, callback: () -> ()) -> JavaScriptKit.JSTimer at wasm-function[415]:0x4889e
  partial apply forwarder for closure #1 (Array<JavaScriptKit.JSValue>) -> () in JavaScriptKit.JSTimer.init(millisecondsDelay: Double, isRepeating: Bool, callback: () -> ()) -> JavaScriptKit.JSTimer at wasm-function[411]:0x486f4
  closure #1 (Array<JavaScriptKit.JSValue>) -> JavaScriptKit.JSValue in JavaScriptKit.JSClosure.init((Array<JavaScriptKit.JSValue>) -> ()) -> JavaScriptKit.JSClosure at wasm-function[814]:0x5cb90
  partial apply forwarder for closure #1 (Array<JavaScriptKit.JSValue>) -> JavaScriptKit.JSValue in JavaScriptKit.JSClosure.init((Array<JavaScriptKit.JSValue>) -> ()) -> JavaScriptKit.JSClosure at wasm-function[813]:0x5caeb
  reabstraction thunk helper from @escaping @callee_guaranteed (@guaranteed Array<JavaScriptKit.JSValue>) -> (@owned JavaScriptKit.JSValue) to @escaping @callee_guaranteed (@in_guaranteed Array<JavaScriptKit.JSValue>) -> (@out JavaScriptKit.JSValue) at wasm-function[810]:0x5c955
  partial apply forwarder for reabstraction thunk helper from @escaping @callee_guaranteed (@guaranteed Array<JavaScriptKit.JSValue>) -> (@owned JavaScriptKit.JSValue) to @escaping @callee_guaranteed (@in_guaranteed Array<JavaScriptKit.JSValue>) -> (@out JavaScriptKit.JSValue) at wasm-function[809]:0x5c91d
  reabstraction thunk helper from @escaping @callee_guaranteed (@in_guaranteed Array<JavaScriptKit.JSValue>) -> (@out JavaScriptKit.JSValue) to @escaping @callee_guaranteed (@guaranteed Array<JavaScriptKit.JSValue>) -> (@owned JavaScriptKit.JSValue) at wasm-function[837]:0x5f875
  partial apply forwarder for reabstraction thunk helper from @escaping @callee_guaranteed (@in_guaranteed Array<JavaScriptKit.JSValue>) -> (@out JavaScriptKit.JSValue) to @escaping @callee_guaranteed (@guaranteed Array<JavaScriptKit.JSValue>) -> (@owned JavaScriptKit.JSValue) at wasm-function[829]:0x5f511
  JavaScriptKit._call_host_function_impl(UInt32, UnsafePointer<__C.RawJSValue>, Int32, UInt32) -> () at wasm-function[828]:0x5f13d
  _call_host_function_impl at wasm-function[827]:0x5ecad
  _call_host_function at wasm-function[21130]:0x5ac7c8
  callHostFunction at ./node_modules/javascript-kit-swift/Runtime/lib/index.js?:110:21
  swjs_create_function/func_ref< at ./node_modules/javascript-kit-swift/Runtime/lib/index.js?:295:28
@MaxDesiatov MaxDesiatov added the bug Something isn't working label Dec 6, 2020
MaxDesiatov pushed a commit that referenced this issue May 31, 2021
…) (#407)

When _domRef is used to directly modify the DOM, this causes the state of the DOM to no longer match the View from which it was rendered. When the renderer later tries to unmount the modified element, this can cause a crash.

This PR fixes the crash by catching (and ignoring) this failure in DOMRenderer.unmount. This fixes #326 and #369, which are the same issue.

Note that directly modifying the DOM with `_domRef` can still cause problems, as the state mismatch remains. For example, an update to the `View` can cause the renderer to overwrite those DOM changes.
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Development

Successfully merging a pull request may close this issue.

1 participant