Relax HarwareKeyboard assert on first received event #131258
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR updates the
HardwareKeyboardto not assert for the first up or down event.Since #122885 (and the related PRs on engine side), the
HardwareKeyboardis initialized with the known keyboard state returned by the engine.Because the engine sent keyboard event using channel buffers which are created with the default buffer size (which is 1), the first event received on framework side might be an obsolete buffered event.
This PR take a no-risk approach which is to relax two kinds of assert for the very first received event. This logic will only apply to debug mode and apply for only two cases:
An alternative would be to set buffer size to 0 but it is risky because it will apply to release mode and none of the existing channels does set its buffer size to 0.
Related Issue
Fixes #125975
Tests
Adds 2 tests.