Skip to content

IOS7: Implement use of Dispatch Sources to drive timeHandler - #4948

Merged
larsamannen merged 3 commits into
scummvm:masterfrom
larsamannen:ls_fixes
May 2, 2023
Merged

IOS7: Implement use of Dispatch Sources to drive timeHandler#4948
larsamannen merged 3 commits into
scummvm:masterfrom
larsamannen:ls_fixes

Conversation

@larsamannen

Copy link
Copy Markdown
Contributor

Implement use of Dispatch Sources to drive timeHandler. The timerHandler will run on a background thread and not block the UI.
Include two other minor fixes as well. The first disabling bitcode by default for iOS and tvOS, the using the correct delegate methods depending on iOS version.

Apple never required bitcode to be enabled and with Xcode 14
bitcode is deprecated.

Set bitcode to disabled for iOS and tvOS projects. Else it will
be default on and give a build error due to the libraries in
scummvm-ios7-libs-v3 doesn't include bitcode.
The timeHandler was driven by calls to the pollEvent callback function.
Each time pollEvent was called the timeHandler called the TimeManager
handle function to advance in time and make sure scheduled tasks were
triggered.

This worked good for most game engines but some, e.g. the Hypno engine
was using the TimeManager to schedule tasks without calling pollEvent
since it was expecting nor handling events at the specific point in
time.

Since iOS have threads the timerHandler can be called from a separate
thread and not rely on pollEvent.
Implement timerHandler to use a Timer Dispatch Source which and make
it operate on a background thread rather than the main thread.
Read more on Dispatch Sources here:
https://developer.apple.com/library/archive/documentation/General/
Conceptual/ConcurrencyProgrammingGuide/GCDWorkQueues/GCDWorkQueues.html
The delegate methods application:shouldRestoreApplicationState
is replaced with application:shouldRestoreSecureApplicationState
and the method application:shouldSaveApplicationState with
application:shouldSaveSecureApplicationState.

To support older versions of iOS, put them in a version check
macro.
Comment thread backends/platform/ios7/ios7_app_delegate.mm
@larsamannen
larsamannen merged commit 46d6a76 into scummvm:master May 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants