flutter-tizen / embedder

Flutter embedder for Tizen
BSD 3-Clause "New" or "Revised" License
5 stars 7 forks source link

Prevent possible race condition in NotifyAppControl #54

Closed swift-kim closed 6 months ago

swift-kim commented 6 months ago

AppControlManager is not thread-safe and may cause the following exception (reported by a third-party developer) when the UI thread (Dart code) is notified of an app control event (by NotifyAppControl) and tries to access the associated app control instance through NativeAttachAppControl before the instance is added to AppControlManager on the platform thread.

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Exception: Could not find an instance of AppControl with ID 1.
#0      new AppControl._fromMap (package:tizen_app_control/src/app_control.dart:88:7)
#1      new ReceivedAppControl._fromMap (package:tizen_app_control/src/app_control.dart:263:15)
#2      AppControl.onAppControl.<anonymous closure> (package:tizen_app_control/src/app_control.dart:141:50)
#3      _MapStream._handleData (dart:async/stream_pipe.dart:213:31)
#4      _ForwardingStreamSubscription._handleData (dart:async/stream_pipe.dart:153:13)
#5      _RootZone.runUnaryGuarded (dart:async/zone.dart:1594:10)

I'm not sure if this will fix the error. Let me just give it a try.