Crash when calling javascript on Page Activated in a PageControl

Fuse version 0.26.0 (build 7741)
OSX El Capitan 10.11.6

I’m trying to call a javascript function when a Page is activated (so I can reset some observables back to their default values).

Steps:

  1. Download the “page-control” example (Fuse)
  2. Preview it (Local)
  3. Edit MainView.ux
  4. Find the second page - the one with the <Header>Bread! Eat bread!</Header>
  5. Modify it so it looks like this:
<JavaScript>
	function pringTest() {
		debug_log("This is a test");
	}
</JavaScript>
<Page Activated="{printTest}">
	<Info>
		<Header>Bread! Eat bread!</Header>

Once saved, the simulator shows the following error:

Oops! Something went wrong here.

Type not found:

Uno.EventArgs>.PulseHandle

Please see the Fuse Monitor (Cmd/Ctrl+M) for details

And the Console shows:

Outracks.Simulator.Runtime.TypeNotFound: Type not found: Uno.EventArgs>.PulseHandle
  at Outracks.OptionalNullCoalescing.OrThrow[T] (Optional`1 self, System.Exception e) [0x0000e] in /usr/local/Teamcity/Agents/tcagent-osx-agent01-teamcity-dyson/work/b939dc4c6ac331f9/Source/Outracks.Common/Extensions/OptionalNullCoalescing.cs:74 
  at Outracks.Simulator.Runtime.TypeMap.LoadType (Outracks.Simulator.Bytecode.TypeName typeName) [0x0000d] in /usr/local/Teamcity/Agents/tcagent-osx-agent01-teamcity-dyson/work/b939dc4c6ac331f9/Source/Outracks.Simulator.Runtime/Reflection/TypeMap.cs:52 
  at Outracks.Simulator.Runtime.TypeMap.AntialiasAndLoad (Outracks.Simulator.Bytecode.TypeName typeName) [0x00000] in /usr/local/Teamcity/Agents/tcagent-osx-agent01-teamcity-dyson/work/b939dc4c6ac331f9/Source/Outracks.Simulator.Runtime/Reflection/TypeMap.cs:47 
  at System.Linq.Enumerable+WhereSelectEnumerableIterator`2[TSource,TResult].MoveNext () <0x44ba9a0 + 0x000ec> in <filename unknown>:0 
  at System.Linq.Buffer`1[TElement]..ctor (IEnumerable`1 source) <0x44ba748 + 0x001a8> in <filename unknown>:0 
  at System.Linq.Enumerable.ToArray[TSource] (IEnumerable`1 source) <0x44ba698 + 0x00047> in <filename unknown>:0 
  at Outracks.Simulator.Runtime.TypeMap.TryResolveGenericType (Outracks.Simulator.Bytecode.TypeName typeName) [0x00025] in /usr/local/Teamcity/Agents/tcagent-osx-agent01-teamcity-dyson/work/b939dc4c6ac331f9/Source/Outracks.Simulator.Runtime/Reflection/TypeMap.cs:42 
  at Outracks.Simulator.Runtime.TypeMap.ResolveType (Outracks.Simulator.Bytecode.TypeName typeName) [0x0000b] in /usr/local/Teamcity/Agents/tcagent-osx-agent01-teamcity-dyson/work/b939dc4c6ac331f9/Source/Outracks.Simulator.Runtime/Reflection/TypeMap.cs:32 
  at Outracks.Simulator.Runtime.CompiledTypeReflection.CreateDelegate (System.Object instance, Outracks.Simulator.Bytecode.TypeMemberName methodName, Optional`1 methodArgumentTypes, Outracks.Simulator.Bytecode.TypeName delegateTypeName) [0x00072] in /usr/local/Teamcity/Agents/tcagent-osx-agent01-teamcity-dyson/work/b939dc4c6ac331f9/Source/Outracks.Simulator.Runtime/Reflection/CompiledTypeReflection.cs:91 
  at Outracks.Fuse.Preview.RuntimeObjectPoker.<HookUpReflectionInterface>m__5 (System.Object a, System.String b, System.String[] c, System.String d) [0x00000] in /usr/local/Teamcity/Agents/tcagent-osx-agent01-teamcity-dyson/work/b939dc4c6ac331f9/Source/Outracks.Fuse.Preview/RuntimeObjectPoker.cs:32 
  at Outracks.Simulator.Reflection.DelegateReflection.Outracks.Simulator.Runtime.IReflection.CreateDelegate (Outracks.Simulator.Bytecode.TypeName delegateType, System.Object instance, Outracks.Simulator.Bytecode.TypeMemberName methodName, Optional`1 methodSignature) <0x188f3700 + 0x000ef> in <filename unknown>:0 
  at Outracks.Simulator.Runtime.ScopeClosure.Evaluate (Outracks.Simulator.Bytecode.MethodGroup g) <0x188f3658 + 0x00077> in <filename unknown>:0 
  at Outracks.Simulator.Bytecode.Expression.Match[T] (System.Func`2 a1, System.Func`2 a2, System.Func`2 a3, System.Func`2 a4, System.Func`2 a5, System.Func`2 a6, System.Func`2 a7, System.Func`2 a8, System.Func`2 a9, System.Func`2 a10, System.Func`2 a11, System.Func`2 a12, System.Func`2 a13, System.Func`2 a15, System.Func`2 a16) <0xfbfb328 + 0x00135> in <filename unknown>:0 
  at Outracks.Simulator.Runtime.ScopeClosure.Evaluate (Outracks.Simulator.Bytecode.Expression expression) <0xfbfad88 + 0x00563> in <filename unknown>:0 
  at Outracks.Simulator.Runtime.ScopeClosure.Evaluate (Outracks.Simulator.ImmutableList`1 arguments) <0xfbfb848 + 0x0005b> in <filename unknown>:0 
  at Outracks.Simulator.Runtime.ScopeClosure.Evaluate (Outracks.Simulator.Bytecode.CallStaticMethod m) <0xfbfb7d8 + 0x00037> in <filename unknown>:0 
  at Outracks.Simulator.Bytecode.Expression.Match[T] (System.Func`2 a1, System.Func`2 a2, System.Func`2 a3, System.Func`2 a4, System.Func`2 a5, System.Func`2 a6, System.Func`2 a7, System.Func`2 a8, System.Func`2 a9, System.Func`2 a10, System.Func`2 a11, System.Func`2 a12, System.Func`2 a13, System.Func`2 a15, System.Func`2 a16) <0xfbfb328 + 0x002ac> in <filename unknown>:0 
  at Outracks.Simulator.Runtime.ScopeClosure.Evaluate (Outracks.Simulator.Bytecode.Expression expression) <0xfbfad88 + 0x00563> in <filename unknown>:0 
  at Outracks.Simulator.Runtime.ScopeClosure.Execute (IEnumerable`1 statements) <0xfbfac38 + 0x00077> in <filename unknown>:0 
  at Outracks.Simulator.Runtime.ScopeClosure.Execute (Outracks.Simulator.Bytecode.Lambda lambda, System.Object[] arguments) <0xfbfa8b8 + 0x00157> in <filename unknown>:0 
  at Outracks.Simulator.Runtime.LambdaClosure.Func (System.Object a1) <0x167f19b0 + 0x00064> in <filename unknown>:0 
  at Outracks.Simulator.Runtime.ScopeClosure.Execute (System.Object lambda, System.Object[] arguments) <0x167f14d0 + 0x000e2> in <filename unknown>:0 
  at Outracks.Simulator.Runtime.ScopeClosure.Evaluate (Outracks.Simulator.Bytecode.CallLambda i) <0x167f06a0 + 0x0004f> in <filename unknown>:0 
  at Outracks.Simulator.Bytecode.Expression.Match[T] (System.Func`2 a1, System.Func`2 a2, System.Func`2 a3, System.Func`2 a4, System.Func`2 a5, System.Func`2 a6, System.Func`2 a7, System.Func`2 a8, System.Func`2 a9, System.Func`2 a10, System.Func`2 a11, System.Func`2 a12, System.Func`2 a13, System.Func`2 a15, System.Func`2 a16) <0xfbfb328 + 0x00261> in <filename unknown>:0 
  at Outracks.Simulator.Runtime.ScopeClosure.Evaluate (Outracks.Simulator.Bytecode.Expression expression) <0xfbfad88 + 0x00563> in <filename unknown>:0 
  at Outracks.Simulator.Runtime.ScopeClosure.Execute (IEnumerable`1 statements) <0xfbfac38 + 0x00077> in <filename unknown>:0 
  at Outracks.Simulator.Runtime.ScopeClosure.Execute (Outracks.Simulator.Bytecode.Lambda lambda, System.Object[] arguments) <0xfbfa8b8 + 0x00157> in <filename unknown>:0 
  at Outracks.Simulator.Runtime.LambdaClosure.Func (System.Object a1) <0x167f19b0 + 0x00064> in <filename unknown>:0 
  at Outracks.Simulator.Runtime.LambdaClosure.Action (System.Object a1) <0x167f1980 + 0x0001b> in <filename unknown>:0 
  at Outracks.Simulator.Runtime.ScopeClosure.Execute (System.Object lambda, System.Object[] arguments) <0x167f14d0 + 0x002e5> in <filename unknown>:0 
  at Outracks.Simulator.Runtime.ScopeClosure.Evaluate (Outracks.Simulator.Bytecode.CallLambda i) <0x167f06a0 + 0x0004f> in <filename unknown>:0 
  at Outracks.Simulator.Bytecode.Expression.Match[T] (System.Func`2 a1, System.Func`2 a2, System.Func`2 a3, System.Func`2 a4, System.Func`2 a5, System.Func`2 a6, System.Func`2 a7, System.Func`2 a8, System.Func`2 a9, System.Func`2 a10, System.Func`2 a11, System.Func`2 a12, System.Func`2 a13, System.Func`2 a15, System.Func`2 a16) <0xfbfb328 + 0x00261> in <filename unknown>:0 
  at Outracks.Simulator.Runtime.ScopeClosure.Evaluate (Outracks.Simulator.Bytecode.Expression expression) <0xfbfad88 + 0x00563> in <filename unknown>:0 
  at Outracks.Simulator.Runtime.ScopeClosure.Execute (IEnumerable`1 statements) <0xfbfac38 + 0x00077> in <filename unknown>:0 
  at Outracks.Simulator.Runtime.ScopeClosure.Execute (Outracks.Simulator.Bytecode.Lambda lambda, System.Object[] arguments) <0xfbfa8b8 + 0x00157> in <filename unknown>:0 
  at Outracks.Simulator.Runtime.VirtualMachine.Execute (IReflection reflection, Outracks.Simulator.Bytecode.Lambda lambda, System.Object[] arguments) <0xfbfa648 + 0x000af> in <filename unknown>:0 
  at Outracks.Simulator.Runtime.VirtualMachine.Execute (Outracks.Simulator.Bytecode.Lambda lambda, System.Object[] arguments) <0xfbfa610 + 0x00023> in <filename unknown>:0 
  at Outracks.Simulator.Reifying.OnEnterState () <0x167eba08 + 0x000b7> in <filename unknown>:0 
  at Outracks.Simulator.Application.SetState (Outracks.Simulator.State nextState) <0xef56f78 + 0x00054> in <filename unknown>:0 
  at Outracks.Simulator.Application.OnUpdate () <0xef56ad0 + 0x000c7> in <filename unknown>:0 
  at Fuse.App.Update () <0xef56990 + 0x00026> in <filename unknown>:0 
Type not found: Uno.EventArgs>.PulseHandle

FYI - I also tried this but it crashed again:

<JavaScript>
    function pringTest() {
        debug_log("This is a test");
    }
</JavaScript>
<Page>
	<Activated Handler="{pageActivated}" />
	<Info>
	  <Header>Bread! Eat bread!</Header>

Tried copying the code from: Fuse. This got was closer (no crash), but when the page was clicked, it returned this error:

no UserEvent found: myEvent

Here’s the code:

<JavaScript>
    function eventHandler(args) {
        console.log("myEvent raised with argument 'myArgument': " + args.myArgument);
    }

    module.exports = { eventHandler: eventHandler };
</JavaScript>
<Page>
	<Clicked>
		<RaiseUserEvent EventName="myEvent">
			<UserEventArg Name="myArgument" StringValue="Some value" />
		</RaiseUserEvent>
	</Clicked>
	<Info>
		<Header>Bread! Eat bread!</Header>

Hey M,

first, your upper examples are lacking a module.exports = {...} part, so that might be one cause of why “nothing gets called”. The UX can only tap into variables and functions that you have made available to it from JS through module.exports.

second, and I don’t know if that’s it, but I usually use the Activated trigger like this:

<JavaScript>
function thisIsMySomeFunction() {
  console.log('Oh hey, I was just called!');
};

module.exports = {
  'someFunction': thisIsMySomeFunction
};
</JavaScript>
<!-- ... -->
<!-- here you'd put some UX code for the page that gets activated -->
<!-- ... -->
  <Activated>
    <Callback Handler="{someFunction}" />
  </Activated>

Thanks Uldis - your second suggestion worked!

Using:

<Activated> 
  <Callback Handler="{someFunction}" /> 
</Activated>

I also tried my upper example (with the shorthand syntax I made up?:slight_smile: with a module.exports (duh), but it still crashes. In fact, if I click “Try Again” and then try to quit the simulator, the simulator hangs and I have to force-quit it.

Maybe I should leave the bug report open?

<JavaScript>
	function thisIsMySomeFunction() {
	  console.log('Oh hey, I was just called!');
	};

	module.exports = {
	  someFunction: thisIsMySomeFunction
	};
</JavaScript>
<Page Activated="{thisIsMySomeFunction}">
  <Info>
    <Header>Bread! Eat bread!</Header>

I also see the same issue. Version 0.26 of fuse running on OS X El Capitan while local previewing the app. Example app for repro:

<Page ux:Class="Page1" Activated="{loadHandler}">

gives the error: Type not found: Uno.EventArgs>.PulseHandle

Meanwhile,

<Page ux:Class="Page1">
  <Activated>
    <Callback Handler="{loadHandler}" />
  </Activated>
...

works like a charm.

Thanks for reporting! We have a fix for the PulseHandle-crash in preview and hope to release it soon. :slight_smile:

We expect this fix to ship with Fuse 0.27. I’ll update the thread as soon as it’s out.

Fuse 0.27 is now released https://www.fusetools.com/community/forums/general/fuse_beta_release_027