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

[7_4_X] fix(ios): Fix iOS 8/9 compatibility of timers on main thread, register exception handler #10428

Merged
merged 3 commits into from Nov 8, 2018

Conversation

sgtcoolguy
Copy link
Contributor

JIRA: https://jira.appcelerator.org/browse/TIMOB-26391

Optional Description:
Backport of #10426

JSValue *callbackFunction = [callbackArgs objectAtIndex:0];
[callbackArgs removeObjectAtIndex:0];
double interval = [[callbackArgs objectAtIndex:0] toDouble] / 1000;
[callbackArgs removeObjectAtIndex:0];
JSVirtualMachine *vm = callbackFunction.context.virtualMachine;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For SDK < 8, this should likely use the Ti prefixed JSCore calls, otherwise this could break apps not using JSCore so far.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new timer management is only enabled with JSCore

return [timerIdentifier unsignedIntegerValue];
}

- (void)callJsCallback:(NSTimer *_Nonnull)timer
{
NSArray<JSValue *> *args = [timer userInfo];
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if trying to optimize for the most common case of no additional arguments and setting just the callback as the user info and then checking type here would improve performance or not...

@build
Copy link
Contributor

build commented Nov 8, 2018

Fails
🚫

Tests have failed, see below for more information.

Messages
📖

💾 Here's the generated SDK zipfile.

Tests:

Classname Name Time Error
android.Titanium.UI.TableView appendSection and appendRow (TIMOB-25936) 36.259 Error: timeout of 5000ms exceeded

Generated by 🚫 dangerJS

@sgtcoolguy sgtcoolguy changed the title [7_4_X] fix(ios): Use JSManagedValues to retain the callbacks and additional arguments used by timers: setTimeout/setInterval [7_4_X] fix(ios): Fix iOS 8/9 compatibility of timers on main thread, register exception handler Nov 8, 2018
…r exception handler

- Re-work timers to try and do less ourselves around cleaning up single-shot timers. Keep weak references to timers, let API invalidate those single-shot timers
- Handle unspecified interval/duration, set minimum to 1ms
- Make setTimeout/setInterval/clearTimeout block signatures match expected types (even though we cheat and access JSContext currentArguments for varargs)
@@ -1610,36 +1622,54 @@ - (void)dealloc

- (void)invalidateAllTimers
{
for (NSNumber *timerIdentifier in self.timers.allKeys) {
for (NSNumber *timerIdentifier in self.timers) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it save to iterate directly over the NSMapTable and remove entries?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah good catch.

@sgtcoolguy sgtcoolguy merged commit 4b2e861 into tidev:7_4_X Nov 8, 2018
@sgtcoolguy sgtcoolguy deleted the timers-managed-7_4_X branch November 8, 2018 20:24
sgtcoolguy added a commit that referenced this pull request Nov 8, 2018
… register exception handler (#10428)

* fix(ios): Fix iOS 8/9 compatibility of timers on main thread, register exception handler
- Re-work timers to try and do less ourselves around cleaning up single-shot timers. Keep weak references to timers, let API invalidate those single-shot timers
- Handle unspecified interval/duration, set minimum to 1ms
- Make setTimeout/setInterval/clearTimeout block signatures match expected types (even though we cheat and access JSContext currentArguments for varargs)
rlustemberg pushed a commit to inzdr/titanium_mobile that referenced this pull request Nov 19, 2018
… register exception handler (tidev#10428)

* fix(ios): Fix iOS 8/9 compatibility of timers on main thread, register exception handler
- Re-work timers to try and do less ourselves around cleaning up single-shot timers. Keep weak references to timers, let API invalidate those single-shot timers
- Handle unspecified interval/duration, set minimum to 1ms
- Make setTimeout/setInterval/clearTimeout block signatures match expected types (even though we cheat and access JSContext currentArguments for varargs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants