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);
} }
[shareToDelegate_ passwordAppExDidFinish:activityResult // Password autofill uses JavaScript injection which must be executed on
username:username // the main thread, however,
password:password // loadItemForTypeIdentifier:options:completionHandler: documentation states
completionMessage:message]; // that completion block "may be executed on a background thread", so the
// Controller state can be reset only after delegate has processed the // code to do password filling must be re-dispatched back to main thread.
// item returned from the App Extension. // Completion block intentionally retains |self|.
[self resetUserInterface]; dispatch_async(dispatch_get_main_queue(), ^{
[shareToDelegate_ passwordAppExDidFinish:activityResult
username:username
password:password
completionMessage:message];
// Controller state can be reset only after delegate has
// processed the item returned from the App Extension.
[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