Baseflow / flutter-permission-handler

Permission plugin for Flutter. This plugin provides a cross-platform (iOS, Android) API to request and check permissions.
https://baseflow.com
MIT License
2.03k stars 842 forks source link

Windows crashing issue #1388

Open kirill-21 opened 2 hours ago

kirill-21 commented 2 hours ago

Old windows 10 machines encounter crashing issues related to plugin implementation (even when plugin is not used on this platform).

I have a cross-platform app with Android and Windows support, i added flutter-permission-handler plugin to my android app and do not even use it's code on windows, hover, upon app's launch it crashes with this error (can be only seen with Visual Studio, if app is launched without visualstudio, it just instantly closes when it's launched):

image image image image image image image image

image image image

winrt::hresult_class_not_registered, [[noreturn]] inline WINRT_IMPL_NOINLINE void throw_hresult(hresult const result)

kirill-21 commented 2 hours ago

Suggested fix (add try case wrapper), i tested and it helped: image image

PermissionHandlerWindowsPlugin::PermissionHandlerWindowsPlugin(){
  try {
    m_positionChangedRevoker = geolocator.PositionChanged(winrt::auto_revoke,
      [this](Geolocator const& geolocator, PositionChangedEventArgs e)
      {
      });
  } catch (...) {
    /* Do nothing */
  }
}
void PermissionHandlerWindowsPluginRegisterWithRegistrar(
    FlutterDesktopPluginRegistrarRef registrar) {
  try {
    PermissionHandlerWindowsPlugin::RegisterWithRegistrar(
        PluginRegistrarManager::GetInstance()
            ->GetRegistrar<PluginRegistrarWindows>(registrar));
  } catch (...) {
    /* Do nothing */
  }
}