Reset a11y bridge state on hot restart (flutter/engine#6857)

This commit is contained in:
Dan Field
2018-11-14 11:13:39 -08:00
committed by GitHub
parent 80483a4d58
commit 3ce4d16b63
4 changed files with 19 additions and 4 deletions

View File

@@ -205,7 +205,8 @@ public class FlutterNativeView implements BinaryMessenger {
// Called by native to update the semantics/accessibility tree.
private void updateSemantics(ByteBuffer buffer, String[] strings) {
if (mFlutterView == null) return;
if (mFlutterView == null)
return;
mFlutterView.updateSemantics(buffer, strings);
}
@@ -218,13 +219,17 @@ public class FlutterNativeView implements BinaryMessenger {
// Called by native to notify first Flutter frame rendered.
private void onFirstFrame() {
if (mFlutterView == null) return;
if (mFlutterView == null)
return;
mFlutterView.onFirstFrame();
}
// Called by native to notify when the engine is restarted (cold reload).
// Called by native to notify when the engine is restarted (hot restart).
@SuppressWarnings("unused")
private void onPreEngineRestart() {
if (mFlutterView != null) {
mFlutterView.resetAccessibilityTree();
}
if (mPluginRegistry == null)
return;
mPluginRegistry.onPreEngineRestart();

View File

@@ -129,11 +129,12 @@ class AccessibilityBridge final {
fml::WeakPtr<AccessibilityBridge> GetWeakPtr();
void clearState();
private:
SemanticsObject* GetOrCreateObject(int32_t id, blink::SemanticsNodeUpdates& updates);
void VisitObjectsRecursivelyAndRemove(SemanticsObject* object,
NSMutableArray<NSNumber*>* doomed_uids);
void ReleaseObjects(std::unordered_map<int, SemanticsObject*>& objects);
void HandleEvent(NSDictionary<NSString*, id>* annotatedEvent);
UIView* view_;

View File

@@ -687,4 +687,10 @@ fml::WeakPtr<AccessibilityBridge> AccessibilityBridge::GetWeakPtr() {
return weak_factory_.GetWeakPtr();
}
void AccessibilityBridge::clearState() {
[objects_ removeAllObjects];
previous_route_id_ = 0;
previous_routes_.clear();
}
} // namespace shell

View File

@@ -120,6 +120,9 @@ std::unique_ptr<VsyncWaiter> PlatformViewIOS::CreateVSyncWaiter() {
}
void PlatformViewIOS::OnPreEngineRestart() const {
if (accessibility_bridge_) {
accessibility_bridge_->clearState();
}
if (!owner_controller_) {
return;
}