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

[TIMOB-20217] iOS: Ti.Geolocation.hasGeolocationPermission() and Ti.Geolocation.getCurrentPosition() are not working on IOS 7 - fix for TI_USE_KROLL_THREAD #7656

Merged
merged 1 commit into from
Feb 2, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion iphone/Classes/GeolocationModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,10 @@ - (void)requestLocationPermissioniOS7:(id)args {
-(void)requestLocationPermissions:(id)args
{
if (![TiUtils isIOS8OrGreater]) {
[self requestLocationPermissioniOS7:args];
// It is required that delegate is created and permission is presented in main thread.
TiThreadPerformOnMainThread(^{
[self requestLocationPermissioniOS7:args];
}, NO);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't see any dependency to the TI_USE_KROLL_THREAD, did you test it with both <run-on-mainthread/> and without? Just want to double-check.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually when we run on Studio the JS is executed in a separate thread. <run-on-mainthread/> is false by default. But the permission are required to be presented on main thread.

But when we run in XCode TI_USE_KROLL_THREAD is not defined, which makes JS run on main thread. So it very easy to miss on background thread related issues. This fix is one of them.
This can be tested by defining and un-defining TI_USE_KROLL_THREAD in defines.h. Should work in both cases.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Alright. But if thats the case, we definitely need to make the Xcode builds behave the same as the actual ti build -p ios builds. Would it make sense to define it by default in the Xcode project? Should be the same with <use-autolayout/> that triggers a different behavior.

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 highly recommend that TI_USE_KROLL_THREAD is defined by default in our code base. This makes the Xcode build behave as expected. Actually it is quite easy to miss these thread related issues :(
About this got to check with Kiat.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes. At least if we keep the main thread enabled by default. But as far as I know, I should get enabled by default starting in 6.0.0 in favor of Hyperloop. /cc @cheekiatng

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure we can make TI_USE_KROLL_THREAD default for now in our code base. However, there's a blocker for setting it to default starting in 6.0.0 due to https://jira.appcelerator.org/browse/TIMOB-19762.

return;
}

Expand Down