Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Events are delivered twice to "on event from" handler with value MICROBIT_EVT_ANY #2382

Open
martinwork opened this issue Aug 9, 2019 · 5 comments
Assignees
Labels
bug device For bugs that repro on the device P2

Comments

@martinwork
Copy link
Contributor

Describe the bug

When using an "on event from" handler with value MICROBIT_EVT_ANY, each event is delivered twice.

Tested using Button A events and MES_DPAD events.

Occurs on live and beta but not on v1.

In addition, the simulator shows the wrong events for button A presses..

To Reproduce
Steps to reproduce the behavior:

  1. Go to 'https://makecode.microbit.org/_EFP7X50XiK78'
  2. Download to micro:bit
  3. Press button A down
  4. See Heart-1, Heart-1 repeated
  5. Change "with value" to MICROBIT_BUTTON_EVT_DOWN
  6. Download to micro:bit
  7. Press button A down
  8. See Heart-1 just once

Expected behavior
Each event should be delivered just once each time it is sent.

Desktop (please complete the following information):

  • OS: Windows
  • Browser Chrome
    Live
    makecode.microbit.org version: 2.0.6
    Microsoft MakeCode version: 5.15.12
    microbit runtime version: pxtgc-0

And beta
makecode.microbit.org version: 2.1.4
Microsoft MakeCode version: 5.19.8
microbit runtime version: pxtgc-0

@philipphenkel
Copy link
Contributor

This could be regression caused by the fix for #1334. When fixing this one we should double-check the other test case as well.

Btw, I tested on a device and see a different (wrong) behavior in step 4:
See Heart-1, Heart-1 repeated, See Heart-1, Heart-2 repeated, See Heart-3, Heart-3 repeated

@martinwork
Copy link
Contributor Author

Thanks for confirming @philipphenkel . That is what I see when I press and release, but I left out the details! A quick press-release will be 1,2,3 (down,up,click) or a long press and release will be 1,5,2 (down,hold,up). Each of these events is delivered twice for MICROBIT_EVT_ANY but only event 1 is comparable with the MICROBIT_BUTTON_EVT_DOWN case. I think it's any event too, not just the buttons. I was trying to use the gamepad events.

@philipphenkel
Copy link
Contributor

This could be a duplicate of #2255 (see #2255 (comment) for a generic test example)

@martinwork
Copy link
Contributor Author

Yes @philipphenkel . This looks like the same or very closely related problem.

@martinwork
Copy link
Contributor Author

I think the problem lies in incompatibilities in various versions of findBinding and dispatchEvent.

See microsoft/pxt-common-packages@1167fa3

The action of findBinding has been changed to return the ANY binding as well as the requested one, with the addition of a nextBinding function and insertion of the old findBinding implementation into setBinding.

The implementations of dispatchEvent in pxt-common-packages have been changed to use the new findBinding and nextBinding, but the implementation of dispatchEvent in pxt-microbit assumes the old findBinding behaviour. It tries to find the specific binding then the ANY binding, but will find the ANY binding twice unless the specific one is first in the list (defined last).

@abchatra abchatra added device For bugs that repro on the device and removed next-release labels Mar 21, 2020
@pelikhan pelikhan assigned tballmsft and unassigned pelikhan Mar 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug device For bugs that repro on the device P2
Projects
None yet
Development

No branches or pull requests

5 participants