Skip to content

I think the set function of the use_state object affects the other mutex usage. #2920

@myyrakle

Description

@myyrakle

Problem
In certain logic "main loop" and "event action" access shared data via mutex.
Originally there was no problem, but as soon as I used the set of use_state the problem started. What is done writing in "main loop" is not visible in "event action".

If I removed use_statue.set, it worked as expected again.

The link below is my code where the problem occurred.
If you run it, it should be reproducible.
https://github.com/myyrakle/rustetris/blob/8e7e5389a5cfaa3113ee7606fc79090ad5822f5c/src/components/gamebox.rs#L24

Steps To Reproduce
Steps to reproduce the behavior:

  1. Execute the above code as it is.
  2. Press the start button and the tetris game will start.
  3. Press the left and right arrow keys to move.
  4. Uncomment the set function and run it again.
  5. It will not move even if you press the left and right arrow keys. (The error is due to the mutex sync failure issue mentioned above.)

Expected behavior

Screenshots
image

Environment:

  • Yew version: 0.19
  • Rust version: 1.64 stable
  • Target, if relevant: wasm32-unknown-unknown
  • Build tool, if relevant: trank
  • OS, if relevant: windows 11
  • Browser and version, if relevant: not relevant

Questionnaire

  • I'm interested in fixing this myself but don't know where to start
  • I would like to fix and I have a solution
  • I don't have time to fix this right now, but maybe later

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions