9

Bug found: Race condition when updating scene elements

When programmatically updating two scene elements, one element will get the value of the other, at least for Number Pickers. `new_val` acts like a Singleton having just one state.

I've been seeing this behavior for the Expiry Hours element. Logging shows one value of `%new_val` before the assignment and a different value after the assignment.

Logging shows `eh` eventually getting the value meant for `em`.

06.47: eh: 47 <- 47,06.47: em: 47 -> 47,06.47: eh: 07 -> 7,06.47: expiry minutes: 47,06.47: expiry hours: 07
Profile: Volume Profile When Phone Shaken (81)
        Event: Shake [ Axis:Left-Right Sensitivity:Medium Duration:Medium ]
Enter: Start Volume Profile Scene (80)
        A1: Variable Set [ Name:%TIMED_VOLUME_PROFILE_DURATION_HOURS To:01 Recurse Variables:Off Do Maths:Off Append:Off ] 
        A2: Variable Set [ Name:%TIMED_VOLUME_PROFILE_DURATION_MINUTES To:00 Recurse Variables:Off Do Maths:Off Append:Off ] 
        A3: Show Scene [ Name:Volume Profile Display As:Activity Horizontal Position:100 Vertical Position:100 Animation:System Show Exit Button:On Show Over Keyguard:On Continue Task Immediately:On ] 
        A4: Variable Set [ Name:%VOLUME_PROFILE_SCENE_ACTIVE To:true Recurse Variables:Off Do Maths:Off Append:Off ] 
        A5: Variable Set [ Name:%UPDATE_TIMED_VOLUME_PROFILE_WIDGET_TASK To:UpdateTimedVolumeProfileExpiryWidget Recurse Variables:Off Do Maths:Off Append:Off ] 
        A6: Perform Task [ Name:%UPDATE_TIMED_VOLUME_PROFILE_WIDGET_TASK Priority:%priority Parameter 1 (%par1): Parameter 2 (%par2): Return Value Variable: Stop:Off ] 

Profile: Update Timed Volume Profile Widget (56)
        State: Task Running [ Name:Start Volume Profile Scene ]
Enter: UpdateTimedVolumeProfileWidget (57)
        
        A1: Anchor 
        A2: Perform Task [ Name:SecondsUntilNextMinute Priority:%priority Parameter 1 (%par1): Parameter 2 (%par2): Return Value Variable:%seconds Stop:Off ] 
        A3: Wait [ MS:0 Seconds:%seconds Minutes:0 Hours:0 Days:0 ] 
        A4: If [ %VOLUME_PROFILE_SCENE_ACTIVE ~ true ]
        A5: Perform Task [ Name:Log Priority:%priority Parameter 1 (%par1):auto calling %UPDATE_TIMED_VOLUME_PROFILE_WIDGET_TASK Parameter 2 (%par2): Return Value Variable: Stop:Off ] 
        A6: Perform Task [ Name:%UPDATE_TIMED_VOLUME_PROFILE_WIDGET_TASK Priority:%priority Parameter 1 (%par1): Parameter 2 (%par2): Return Value Variable: Stop:Off ] 
        A7: Goto [ Type:Action Label Number:1 Label:TOP ] 

Exit: Destroy Volume Profile Scene (85)
        Run Both Together
        A1: Variable Set [ Name:%VOLUME_PROFILE_SCENE_ACTIVE To:false Recurse Variables:Off Do Maths:Off Append:Off ] 
        A2: Destroy Scene [ Name:Volume Profile ]