Commit 265a292b authored by Peter K. Lee's avatar Peter K. Lee Committed by Commit Bot

Redispatch JavaScript to main thread if it is not

Password filling uses JavaScript injection, so it must be ran on main
thread. iOS 11 runs the Extension callback on a non-main thread
and results in a crash. This CL fixes this be detecting that the crucial
piece of code is not on main thread and re-dispatches it.

Bug: 742554
Change-Id: I7a337e424800052069dfd207903d17da8df04458
Reviewed-on: https://chromium-review.googlesource.com/572701Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Reviewed-by: default avatarMike Dougherty <michaeldo@chromium.org>
Commit-Queue: Peter Lee <pkl@chromium.org>
Cr-Commit-Position: refs/heads/master@{#487185}
parent ce740243
...@@ -276,13 +276,21 @@ ...@@ -276,13 +276,21 @@
activity_type_util::RecordMetricForActivity(type); activity_type_util::RecordMetricForActivity(type);
message = activity_type_util::CompletionMessageForActivity(type); message = activity_type_util::CompletionMessageForActivity(type);
} }
// Password autofill uses JavaScript injection which must be executed on
// the main thread, however,
// loadItemForTypeIdentifier:options:completionHandler: documentation states
// that completion block "may be executed on a background thread", so the
// code to do password filling must be re-dispatched back to main thread.
// Completion block intentionally retains |self|.
dispatch_async(dispatch_get_main_queue(), ^{
[shareToDelegate_ passwordAppExDidFinish:activityResult [shareToDelegate_ passwordAppExDidFinish:activityResult
username:username username:username
password:password password:password
completionMessage:message]; completionMessage:message];
// Controller state can be reset only after delegate has processed the // Controller state can be reset only after delegate has
// item returned from the App Extension. // processed the item returned from the App Extension.
[self resetUserInterface]; [self resetUserInterface];
});
}; };
[itemProvider loadItemForTypeIdentifier:(NSString*)kUTTypePropertyList [itemProvider loadItemForTypeIdentifier:(NSString*)kUTTypePropertyList
options:nil options:nil
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment