Can't call function when sender is unrooted

Hi All,

It works fine when it calls the function first. I’m getting the above error when I call a second time. If “Slider.ux”, “value-changed” when it is removed, the statement works seamlessly. Does anyone have an idea?

Log

Preview detected an unhandled exception: System.AggregateException: One or more errors occurred. ---> System.Exception: Can't call function when sender is unrooted

MainView.js

function send_to_api(device_id, SLIDER_POS) {
    var switch_pos = 0;

    if ((SLIDER_POS == 0) ? switch_pos = 0 : switch_pos = 1);

    var body = { "id" : device_id, "param_value" : SLIDER_POS };

    fetch(DEVICE_URL, {      method: 'post',
      body: JSON.stringify(body),
      headers: new Headers({
        'Content-Type': 'application/json',
        'Authorization': 'Token ' + token.value
    })
    })
    .then(function(response) { 
      return response.json(); 
    })
    .then(function(responseObject) {
      if (status.value == 200) {
          api_retval.replaceAll(responseObject);
      }
    }).catch(function (err) {
        msg.value = err;
    });
}

module.exports = {
  ...
  ...
  ...
  SwitchChanged: function (args) {
    switch_pos = args.value;
    if ( (switch_pos == true) ? send_to_api(args.data.id, SLIDER_POS) : send_to_api(args.data.id, 0) );
  },
  SliderValueChanged: function (args) {
    var _slider_pos = 0;

    _slider_pos = args.value;
    SLIDER_POS = _slider_pos.toFixed(0);

    if ( (SLIDER_POS < 1) ? send_to_api(args.data.id, "0") : send_to_api(args.data.id, SLIDER_POS) );
  }
};

Slider.ux

<ScrollView>
  <DockPanel>
    <Each Items="{data}">
      <StackPanel Dock="Top" Height="50" Margin="10,5">
        <Panel>
          <Text Font="MainView.RobotoRegular" TextColor="#fff" Opacity=".8" Alignment="VerticalCenter" Value="{name}" />

          <Slider Margin="180,10" Padding="5,10,10,10" Width="145" ValueChanged="{SliderValueChanged}" Value="{slider_value}" Minimum="0" Maximum="255" />

          <Switch Value="False" Name="TheSwitch" ValueChanged="{SwitchChanged}" Alignment="CenterRight" />
          <WhileFloat Value="{slider_value}" GreaterThan="1" LessThan="255">
          <Change TheSwitch.Value="True" />
          </WhileFloat>        </Panel>

          <Rectangle Layer="Background" CornerRadius="15" Color="{Resource lightBlue800}" />
      </StackPanel>
    </Each>
  </DockPanel>
</ScrollView>

When the above procedure carried out on the phone getting the following error message.

fuse preview -t=Android

I/SmartHome(28763): One or more errors occurred.
I/SmartHome(28763): Preview detected an unhandled exception: Uno.AggregateException: One or more errors occurred.
I/SmartHome(28763):    at Fuse.UpdateManager.Update(Fuse.Stage)
I/SmartHome(28763):    at Fuse.UpdateManager.Update()
I/SmartHome(28763):    at Fuse.AppBase.OnUpdate()
I/SmartHome(28763):    at Outracks.Simulator.Application.OnUpdate()
I/SmartHome(28763):    at Fuse.App.FrameCallback.doFrame(long)

Onur: Did you try version 0.10 ?

Yes.

Okay, thanks for reporting this.

Can you please upload a complete test case? If you don’t want to upload it here, you can email it to support@fusetools.com

Dear Anders,

I sent the project files. Thank you for your interest.

The source of the problem is definitely the WhileFloat call. It gives application error when used WhileFloat.

Thanks for the test case, we will investigate!

Problem Slider.ux

<ScrollView>
  <DockPanel>
    <Each Items="{data}">
      <StackPanel Dock="Top" Height="50" Margin="10,5">
        <Panel>
          <Text Font="MainView.RobotoRegular" TextColor="#fff" Opacity=".8" Alignment="VerticalCenter" Value="{name}" />

          <Slider Margin="180,10" Padding="5,10,10,10" Width="145" ValueChanged="{SliderValueChanged}" Value="{slider_value}" Minimum="0" Maximum="255" />

          <Switch Value="False" Name="TheSwitch" ValueChanged="{SwitchChanged}" Alignment="CenterRight" />
          <WhileFloat Value="{slider_value}" GreaterThan="1" LessThan="255">
          <Change TheSwitch.Value="True" />
          </WhileFloat>        </Panel>

          <Rectangle Layer="Background" CornerRadius="15" Color="{Resource lightBlue800}" />
      </StackPanel>
    </Each>
  </DockPanel>
</ScrollView>

When I removed <Change> in <WhileFloat> is working properly.

Working Slider.ux
<ScrollView>
  <DockPanel>
    <Each Items="{data}">
      <StackPanel Dock="Top" Height="50" Margin="10,5">
        <Panel>
          <Text Font="MainView.RobotoRegular" TextColor="#fff" Opacity=".8" Alignment="VerticalCenter" Value="{name}" />

          <Slider Margin="180,10" Padding="5,10,10,10" Width="145" ValueChanged="{SliderValueChanged}" Value="{slider_value}" Minimum="0" Maximum="255" />

          <Switch Value="False" Name="TheSwitch" ValueChanged="{SwitchChanged}" Alignment="CenterRight" />

          <WhileFloat Value="{dim_value}" GreaterThan="1" LessThan="255">
              <!-- <Change TheSwitch.Value="True" /> -->
          </WhileFloat>

        </Panel>

          <Rectangle Layer="Background" CornerRadius="15" Color="{Resource lightBlue800}" />
      </StackPanel>
    </Each>
  </DockPanel>
</ScrollView>

Hi!

I have your test case now, but I’m unable to reproduce the issue. Can you please provide exact steps I need to do inside the app to reproduce the error? Including login information, if I need to log into the app to reproduce it.

Hi,

I sent the login information present in an email.

steps
  • Login
  • Select Location
  • Select Lamp from menu
  • Exit Lamp
  • Select Location
  • Select Lamp from menu again (will crash)

Do I need a specific username/password to log in? I get wrong username/password