Reset a11y bridge state on hot restart (flutter/engine#6857)
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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_;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -120,6 +120,9 @@ std::unique_ptr<VsyncWaiter> PlatformViewIOS::CreateVSyncWaiter() {
|
||||
}
|
||||
|
||||
void PlatformViewIOS::OnPreEngineRestart() const {
|
||||
if (accessibility_bridge_) {
|
||||
accessibility_bridge_->clearState();
|
||||
}
|
||||
if (!owner_controller_) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user