react-native-oauth icon indicating copy to clipboard operation
react-native-oauth copied to clipboard

Open safariViewController from main thread

Open tqc opened this issue 8 years ago • 6 comments

Fixes a crash when immediately reopening the safari view.

tqc avatar Aug 28 '17 08:08 tqc

HI Tom. I think your pull request may be a fix for my problem.

2017-09-11 07:30:12.780 TimeTrackerMobile[17121:1727273] authorize ----> {
    "access_token_url" = "https://github.com/login/oauth/access_token";
    "api_url" = "https://api.github.com";
    "app_name" = timetracker;
    "auth_version" = "2.0";
    "authorize_url" = "https://github.com/login/oauth/authorize";
    "callback_url" = "timetracker://oauth";
    "client_id" = e0...48;
    "client_secret" = d2...b8;
    scopes = email;
} <DCTOAuth2Account: 0x60000033d880; type = github; identifier = B83AA7B7-F783-47EF-B038-533A7458D38F; credential = (null)>
2017-09-11 07:30:59.290 TimeTrackerMobile[17121:1727228] *** Assertion failure in -[UIKeyboardTaskQueue waitUntilAllTasksAreFinished], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3600.7.47/Keyboard/UIKeyboardTaskQueue.m:432
2017-09-11 07:30:59.303 TimeTrackerMobile[17121:1727228] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UIKeyboardTaskQueue waitUntilAllTasksAreFinished] may only be called from the main thread.'
*** First throw call stack:
(
	0   CoreFoundation                      0x0000000109b86b0b __exceptionPreprocess + 171
	1   libobjc.A.dylib                     0x0000000108a3c141 objc_exception_throw + 48
	2   CoreFoundation                      0x0000000109b8acf2 +[NSException raise:format:arguments:] + 98
	3   Foundation                          0x0000000106cbf536 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 193
	4   UIKit                               0x0000000107d13f6f -[UIKeyboardTaskQueue waitUntilAllTasksAreFinished] + 165
	5   UIKit                               0x0000000107494515 -[UIKeyboardImpl setDelegate:force:] + 1372
	6   UIKit                               0x00000001078aa63d -[UIPeripheralHost(UIKitInternal) _reloadInputViewsForResponder:] + 992
	7   UIKit                               0x00000001078b3c4b -[UIPeripheralHost(UIKitInternal) _preserveInputViewsWithId:animated:reset:] + 499
	8   UIKit                               0x000000010738a35d -[UIViewController _presentViewController:modalSourceViewController:presentationController:animationController:interactionController:completion:] + 1145
	9   UIKit                               0x000000010738bfae -[UIViewController _presentViewController:withAnimationController:completion:] + 4660
	10  UIKit                               0x000000010738ee8a -[UIViewController _performCoordinatedPresentOrDismiss:animated:] + 532
	11  UIKit                               0x000000010738e962 -[UIViewController presentViewController:animated:completion:] + 181
	12  TimeTrackerMobile                   0x00000001061693d9 __34+[OAuthManager setupOAuthHandler:]_block_invoke + 281
	13  DCTAuth                             0x0000000106ba55bc -[DCTAuthPlatform openURL:completion:] + 252
	14  DCTAuth                             0x0000000106bab505 -[DCTAuthURLOpenerOperation start] + 181
	15  Foundation                          0x0000000106c295fc __NSOQSchedule_f + 198
	16  libdispatch.dylib                   0x000000010bfad05c _dispatch_client_callout + 8
	17  libdispatch.dylib                   0x000000010bf8b94f _dispatch_queue_serial_drain + 221
	18  libdispatch.dylib                   0x000000010bf8c669 _dispatch_queue_invoke + 1084
	19  libdispatch.dylib                   0x000000010bf8eec4 _dispatch_root_queue_drain + 634
	20  libdispatch.dylib                   0x000000010bf8ebef _dispatch_worker_thread3 + 123
	21  libsystem_pthread.dylib             0x000000010c3445a2 _pthread_wqthread + 1299
	22  libsystem_pthread.dylib             0x000000010c34407d start_wqthread + 13
)

Is there a related issue for this?

hpinsley avatar Sep 11 '17 11:09 hpinsley

I can confirm that this works for me! I was scratching my head over this one!

joncursi avatar Oct 04 '17 13:10 joncursi

Yea this one is pretty insidious; happens to me in my app about 50% of the time right now. Would love to see this get merged...

ArtisanalPickle avatar Nov 01 '17 03:11 ArtisanalPickle

Can confirm this corrects a problem we were seeing with an app we have that opens the web view on a refresh.

To hopefully help anyone coming from a search engine, the error we were getting was:

accessing _cachedSystemAnimationFence requires the main thread ...

blakek avatar Jan 11 '18 18:01 blakek

Any plan to merge this in soon?

johnyoonh avatar Mar 03 '18 21:03 johnyoonh

@johnyoonh Our team forked this to https://github.com/gsandf/react-native-oauth because this repo seems inactive. We pulled this PR in and made a couple other fixes where this wasn't following the OAuth 2.0 spec, including:

  • scopes must be separated by spaces (section 3.3)
  • the client secret must not be sent in the request URI when fetching the access token (section 2.3.1)

We'd love to help get this working with OAuth 2.0 if this becomes active again.

blakek avatar Mar 07 '18 20:03 blakek