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
Add high-frequency touch events to iOS GameView #8092
Conversation
MonoGame 3.8 Release
Update master
Fix Missing Android Package
In other `Platform` classes (such as `SDLGamePlatform` and `AndroidGamePlatform`, `Threading.Run()` is called during `Tick()` or `RunLoop()` (inconsistently, it may be called before or after `Game.Tick()` unfortunately). Fixing this for `iOSGamePlatform`. `WinForms` and perhaps other platforms (Switch?) may suffer from the same issue. Note that texture loading from background thread is discouraged however a lot of computationally intensive operations (reading/decoding the image file streams, allocating CPU buffers) could be done in the background thread and hence is a good practice to move such work alone into the bgthread until we request the actual texture from the main thread.
@harry-cpp @mrhelmut Could you please help review? thank you! |
On the PR itself, there are several regression issues that need to be addressed. Please collapse the commits. There are thread timing issues that need to be formally addressed since the entire TouchCollection becomes asynchronous. Rather than passing an event through the framework for this case, set a listener, hook with callback delagate, for the event and call the handler(a static function elsewhere) in Program.cs or Activity.cs. That was how I handled the delay issue on Android and Windows. What are the associated costs:
|
Could you add what the regressions are to the PR comments? Not seeing it... The coalesced events (+processing) is optional (existing apps can choose to subscribe by adding I am not aware of any thread timing issues as the In case I am missing something, please clarify / provide specific examples. |
@harry-cpp @mrhelmut could you please take a look? Thanks! |
@@ -1,7 +1,7 @@ | |||
#region License | |||
// /* | |||
// Microsoft Public License (Ms-PL) | |||
// MonoGame - Copyright � 2009-2010 The MonoGame Team | |||
// MonoGame - Copyright � 2009-2010 The MonoGame Team |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happened here @Mindfulplays ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codepage issues (apparently, VS Code says UTF-8!), just made it (C) :) note that GH diff shows/has codepage issues in the 'before' too for this file and the other ones, so fixed both.
Hey @Mindfulplays There are some changes to readme.md files in this PR. Is that in other PR somewhere? Are we waiting for that to be merged? |
Apologies, non-familiarity with gh workflows, accidental, removed. |
Please take a look, I resolved your comments. |
Thanks @Mindfulplays |
I take it @Mindfulplays there is not an Android equivalent path for Android? (as this PR only focuses on iOS) |
There is: we can get History of touch events in Android. I will send a separate patch for that. Similarly we have DirectManipulation in Windows but that might be a moot point as I am not sure if it's useful in the context of Windows tablets as a market compared to mobile. (Thoughts?) |
Also am not sure if there is such a thing on Consoles (may be Switch or Steam Deck?), but I don't have access to Consoles SDKs so currently wouldn't be able to dabble in it. |
If it is available on Android, then it would make sense @Mindfulplays to have parity there. As for consoles, only Switch really would be compatible (possibly steam deck) but again, they are not touch-first devices, so I do not think we need to worry about those. |
This is one of those features where it may only be available on a couple of platforms. We should come up with a way to document what platforms these features work on. Is there some sort of reference document tag we can use for this? If not maybe some sort of common language in reference docs like:
We would just need to be sure to keep this up to date. |
Added Android support + doc in #8109 |
* Fix iOS GamePlatform to run pending background tasks MonoGame#7520 In other `Platform` classes (such as `SDLGamePlatform` and `AndroidGamePlatform`, `Threading.Run()` is called during `Tick()` or `RunLoop()` (inconsistently, it may be called before or after `Game.Tick()` unfortunately). Fixing this for `iOSGamePlatform`. `WinForms` and perhaps other platforms (Switch?) may suffer from the same issue. Note that texture loading from background thread is discouraged however a lot of computationally intensive operations (reading/decoding the image file streams, allocating CPU buffers) could be done in the background thread and hence is a good practice to move such work alone into the bgthread until we request the actual texture from the main thread. * Update docs for sync/test code * Fix typo in comment * Add coalesced touch events to iOS GameView * Add coalesced touch API to TouchPanel* * Fix UTF-8 copyright mistake * Ensure we process coalesced touches only if the client asked for it * Avoid using C#5.0+ features (expression-bodied properties) * Suggested changes * Remove Coalesced API (new) and update existing touch event with a flag for `isHighFrequency`. - Also consistently use `high-frequency` instead of `coalesced` when referring to this new behavior. * Remove `out int` C# 7.0 / use C# 5.0 feature instead * Update based on @harry-cpp comments * Rename to `origin` instead of `upstream` * Remove git stuff * Address PR comments * Change (c) UTF-8 due to codepage issues, my bad. --------- Co-authored-by: Tom Spilman <tom@sickheadgames.com> Co-authored-by: Thao D <thao.mindfulplay@gmail.com> Co-authored-by: Simon (Darkside) Jackson <darkside@zenithmoon.com> Co-authored-by: mindfulplay.build <mindfulplay@appu.app>
* Fix iOS GamePlatform to run pending background tasks MonoGame#7520 In other `Platform` classes (such as `SDLGamePlatform` and `AndroidGamePlatform`, `Threading.Run()` is called during `Tick()` or `RunLoop()` (inconsistently, it may be called before or after `Game.Tick()` unfortunately). Fixing this for `iOSGamePlatform`. `WinForms` and perhaps other platforms (Switch?) may suffer from the same issue. Note that texture loading from background thread is discouraged however a lot of computationally intensive operations (reading/decoding the image file streams, allocating CPU buffers) could be done in the background thread and hence is a good practice to move such work alone into the bgthread until we request the actual texture from the main thread. * Update docs for sync/test code * Fix typo in comment * Add coalesced touch events to iOS GameView * Add coalesced touch API to TouchPanel* * Fix UTF-8 copyright mistake * Ensure we process coalesced touches only if the client asked for it * Avoid using C#5.0+ features (expression-bodied properties) * Suggested changes * Remove Coalesced API (new) and update existing touch event with a flag for `isHighFrequency`. - Also consistently use `high-frequency` instead of `coalesced` when referring to this new behavior. * Remove `out int` C# 7.0 / use C# 5.0 feature instead * Update based on @harry-cpp comments * Rename to `origin` instead of `upstream` * Remove git stuff * Address PR comments * Change (c) UTF-8 due to codepage issues, my bad. --------- Co-authored-by: Tom Spilman <tom@sickheadgames.com> Co-authored-by: Thao D <thao.mindfulplay@gmail.com> Co-authored-by: Simon (Darkside) Jackson <darkside@zenithmoon.com> Co-authored-by: mindfulplay.build <mindfulplay@appu.app>
Fine-grained/high-frequency touch events are available in certain platforms upon request. On iOS,
coalesced touch events
can be obtained from theGetCoalescedTouch
via the passed-in event.This PR proposes a side-channel
OnCoalescedTouchEvent
that can be used in lieu or in addition toOnTouchEvent
without any performance penalty. I have tested with and without the coalesced touch event including Apple Pencil which produces events > 60 events per second.Also fixed minor typos here and there (going forward, I will create smaller commit PRs to avoid polluting).