-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[TIMOB-26226] iOS: Remove Kroll-Thread #10196
Conversation
Generated by 🚫 dangerJS |
iphone/Classes/KrollContext.m
Outdated
@@ -147,17 +147,8 @@ TiValueRef ThrowException(TiContextRef ctx, NSString *message, TiValueRef *excep | |||
|
|||
static TiValueRef MakeTimer(TiContextRef context, TiObjectRef jsFunction, TiValueRef fnRef, TiObjectRef jsThis, TiValueRef durationRef, BOOL onetime) | |||
{ | |||
static dispatch_once_t timerInitializer; |
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.
Are you certain there's no thread contention here any more?
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.
I think it is a left-over from the initial kroll-thread deprecation. We used NSLock
context-locks in some other places to guard race conditions, but these should not even occur with main thread enabled. I'll write up some setTimeout
penetration tests to validate this behavior.
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.
This seems to work fine so far (git-diffing where the initial locking came from):
var win = Ti.UI.createWindow({
backgroundColor: '#fff'
});
var btn = Ti.UI.createButton({
title: 'Trigger'
});
btn.addEventListener('click', function() {
setInterval(function () {
Ti.API.info('INTERVAL');
}, 1000);
setTimeout(function () {
Ti.API.info('1');
setTimeout(function() {
Ti.API.info('LAST');
}, 500);
}, 50);
setTimeout(function () {
Ti.API.info('2');
}, 100);
setTimeout(function () {
Ti.API.info('3');
}, 150);
setTimeout(function () {
Ti.API.info('4');
}, 200);
setTimeout(function () {
Ti.API.info('5');
}, 250);
});
win.add(btn);
win.open();
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.
CR looks good to me.
dispatch_once(&timerInitializer, ^{ | ||
timerIDLock = [[NSLock alloc] init]; | ||
}); | ||
|
||
static double kjsNextTimer = 0; |
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.
Maybe my lack of Obj-C expertise is shining through here, but shouldn't the static variable be declared/initialized somewhere else? Does this only set it to 0 the very first time? Or will every timer id == 0?
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.
It actually increases correctly, but you are right, it should rather be instance-scoped like here, although it doesn't really affect it here.
@hansemannn I assume there's also some CLI code related to passing along the main thread/kroll thread value to the build? We should probably rip that out (and/or spit out an error/warning if they are explicitly trying to use Kroll thread which we no longer support). |
@sgtcoolguy I updated the CLI to spit out a warning if the kroll-thread is explicitely used via tiapp.xml. Before merging this, we should really think about Android as well, as it seems it was never really deprecated in code there and was not even used by default, although running Ti SDK 7+. @jquick-axway Are we save to run on the main-thread on Android? |
Yes. We mainly test Android apps whose JS runtime is configured for the main thread already. I'm all for this change. Edit: |
Yep, it seems to be TIMOB-24605 which I think we can fix independently from this one. |
@hansemannn, I also remember the iOS activity indicator can animate while the main UI thread is blocked, but Android and Windows do not support this. Although, the best solution to this problem is to have "ti.worker" support on all platforms and avoid blocking the UI thread. (Android does have a |
JIRA: https://jira.appcelerator.org/browse/TIMOB-26226