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 846 forks source link

Thread 1: EXC_BAD_ACCESS (code=1, address=0x101) #633

Closed Mocaris closed 3 years ago

Mocaris commented 3 years ago

🐛 Bug Report

image

Expected behavior

Reproduction steps

Configuration

permission_handler: ^8.1.4

'$(inherited)',

dart: PermissionGroup.calendar

        # 'PERMISSION_EVENTS=1',
        ## dart: PermissionGroup.reminders
        # 'PERMISSION_REMINDERS=1',
        ## dart: PermissionGroup.contacts
        # 'PERMISSION_CONTACTS=1',
        ## dart: PermissionGroup.camera
         'PERMISSION_CAMERA=1',
        ## dart: PermissionGroup.microphone
        # 'PERMISSION_MICROPHONE=1',
        ## dart: PermissionGroup.speech
        # 'PERMISSION_SPEECH_RECOGNIZER=1',
        ## dart: PermissionGroup.photos
         'PERMISSION_PHOTOS=1',
        ## dart: [PermissionGroup.location, PermissionGroup.locationAlways, PermissionGroup.locationWhenInUse]
         'PERMISSION_LOCATION=1',
        ## dart: PermissionGroup.notification
         'PERMISSION_NOTIFICATIONS=1',
        ## dart: PermissionGroup.mediaLibrary
        # 'PERMISSION_MEDIA_LIBRARY=1',
        ## dart: PermissionGroup.sensors
        # 'PERMISSION_SENSORS=1'

Version: 8.1.4 macOS 11.5 Xcode 12.5.1 Platform:

eldarkk commented 3 years ago

+1

JDDV commented 3 years ago

@Mocaris & @eldarkk, Thank you for bringing this to our attention. I can not get the same the error so I was wondering if you could provide us some more information.

Can you send a code snippet so we can reproduce the same issue, and can you also send your plist.info file? That would be much appreciated, thanks in advance!

Mocaris commented 3 years ago

@JDDV

@Mocaris & @eldarkk, Thank you for bringing this to our attention. I can not get the same the error so I was wondering if you could provide us some more information.

Can you send a code snippet so we can reproduce the same issue, and can you also send your plist.info file? That would be much appreciated, thanks in advance!

image

<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">

CFBundleDevelopmentRegion $(DEVELOPMENT_LANGUAGE) CFBundleDisplayName 密停 CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName flutter_matrix_park CFBundlePackageType APPL CFBundleShortVersionString $(FLUTTER_BUILD_NAME) CFBundleSignature ???? CFBundleURLTypes CFBundleTypeRole Editor CFBundleURLName weixin CFBundleURLSchemes wx3374cd450ff9f3fb CFBundleTypeRole Editor CFBundleURLName alipay CFBundleURLSchemes ap2021001160672101 CFBundleTypeRole Editor CFBundleURLName alipayShare CFBundleURLSchemes ap2021001160672101 CFBundleTypeRole Editor CFBundleURLSchemes mztc CFBundleURLName app CFBundleURLSchemes mt CFBundleVersion $(FLUTTER_BUILD_NUMBER) ITSAppUsesNonExemptEncryption LSApplicationQueriesSchemes iosamap amapuri weixin weixinULAPI LSRequiresIPhoneOS NSAppleMusicUsageDescription App需要您的同意,才能访问Apple Music媒体资料库 NSCameraUsageDescription APP需要您的同意,才能访问相机进行二维码扫描,如禁止将无法使用二维码扫描功能 NSLocationAlwaysAndWhenInUseUsageDescription APP需要您的同意,才能持续访问位置,如禁止将无法持续更新位置信息,这将会影响您的电池续航时间,消耗更多的电量 NSLocationAlwaysUsageDescription App需要您的同意,才能在使用期间持续访问位置 NSLocationTemporaryUsageDescriptionDictionary AMapGeoFenceScene AMapLocationKit 地理围栏功能需要一次精确定位权限才可以正常使用 AMapLocationScene AMapLocationKit 需要一次精确定位权限才可以正常使用 NSLocationUsageDescription App需要您的同意,才能访问位置 CFBundleLocalizations zh_CN CFBundleAllowMixedLocalizations NSLocationWhenInUseUsageDescription App需要您的同意,才能在使用期间访问位置 NSMicrophoneUsageDescription App需要您的同意,才能访问麦克风 NSPhotoLibraryUsageDescription APP需要您的同意,才能访问相册进行选择照片上传/发布信息,如禁止将无法上传选择照片上传/发布信息 UILaunchStoryboardName LaunchScreen UIMainStoryboardFile Main UISupportedInterfaceOrientations UIInterfaceOrientationPortrait UISupportedInterfaceOrientations~ipad UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UIViewControllerBasedStatusBarAppearance io.flutter.embedded_views_preview kTCCServiceMediaLibrary App需要您的同意,才能访问Apple Music媒体资料库
Mocaris commented 3 years ago

@JDDV

@Mocaris & @eldarkk, Thank you for bringing this to our attention. I can not get the same the error so I was wondering if you could provide us some more information.

Can you send a code snippet so we can reproduce the same issue, and can you also send your plist.info file? That would be much appreciated, thanks in advance!

This error occurred when I started the App after updating macOS to 11.5, and the flutter-permission-handler 8.1.3->8.1.4. After I removed the flutter-permission-handler dependency, the project worked fine

Mocaris commented 3 years ago

@Mocaris & @eldarkk,感谢您提请我们注意此事。 我无法得到同样的错误,所以我想知道您是否能向我们提供更多的信息。

Can you send a code snippet so we can reproduce the same issue, and can you also send your plist.info file? 非常感谢,提前感谢!

@Mocaris & @eldarkk, Thank you for bringing this to our attention. I can not get the same the error so I was wondering if you could provide us some more information.

Can you send a code snippet so we can reproduce the same issue, and can you also send your plist.info file? That would be much appreciated, thanks in advance!

eldarkk commented 3 years ago

on ios also such a bug. after updating ios to 14.6, getting crash

eldarkk commented 3 years ago

Update: After reinstall, on first run, crash is gone. Whenever run App 2nd time, crash is there.

Снимок экрана 2021-07-23 в 14 11 16 Снимок экрана 2021-07-23 в 14 27 11 Снимок экрана 2021-07-23 в 14 38 56

permission_handler: ^8.1.4

Deployment Target: ios 10.

Cocoapods: 1.10.1

Info.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>BGTaskSchedulerPermittedIdentifiers</key>
    <array>
        <string>com.transistorsoft.fetch</string>
        <string>com.transistorsoft.customtask</string>
    </array>
    <key>CFBundleDevelopmentRegion</key>
    <string>$(DEVELOPMENT_LANGUAGE)</string>
    <key>CFBundleDisplayName</key>
    <string>$(PRODUCT_NAME)</string>
    <key>CFBundleExecutable</key>
    <string>$(EXECUTABLE_NAME)</string>
    <key>CFBundleIdentifier</key>
    <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>
    <key>CFBundleName</key>
    <string>BLABLABLABLA</string>
    <key>CFBundlePackageType</key>
    <string>APPL</string>
    <key>CFBundleShortVersionString</key>
    <string>$(MARKETING_VERSION)</string>
    <key>CFBundleSignature</key>
    <string>????</string>
    <key>CFBundleVersion</key>
    <string>$(CURRENT_PROJECT_VERSION)</string>
    <key>FDAllFilesDownloadedMessage</key>
    <string>All files have been downloaded</string>
    <key>LSRequiresIPhoneOS</key>
    <true/>
    <key>NSAppTransportSecurity</key>
    <dict>
        <key>NSAllowsArbitraryLoads</key>
        <true/>
    </dict>
    <key>NSAppleMusicUsageDescription</key>
    <string>BLABLABLABLA!</string>
    <key>NSBluetoothAlwaysUsageDescription</key>
    <string>BLABLABLABLA</string>
    <key>NSBluetoothPeripheralUsageDescription</key>
    <string>BLABLABLABLA</string>
    <key>NSCalendarsUsageDescription</key>
    <string>BLABLABLABLA</string>
    <key>NSCameraUsageDescription</key>
    <string>BLABLABLABLA</string>
    <key>NSContactsUsageDescription</key>
    <string>BLABLABLABLA</string>
    <key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
    <string>To make BLABLABLABLA</string>
    <key>NSLocationAlwaysUsageDescription</key>
    <string>To make BLABLABLABLA</string>
    <key>NSLocationWhenInUseUsageDescription</key>
    <string>To get location to BLABLABLABLA</string>
    <key>NSMotionUsageDescription</key>
    <string>BLABLABLABLA!</string>
    <key>NSPhotoLibraryAddUsageDescription</key>
    <string>To get images BLABLABLABLA</string>
    <key>NSPhotoLibraryUsageDescription</key>
    <string>To get BLABLABLABLA</string>
    <key>NSSpeechRecognitionUsageDescription</key>
    <string>BLABLABLABLA</string>
    <key>UIBackgroundModes</key>
    <array>
        <string>fetch</string>
        <string>location</string>
        <string>processing</string>
        <string>remote-notification</string>
    </array>
    <key>UILaunchStoryboardName</key>
    <string>LaunchScreen</string>
    <key>UIMainStoryboardFile</key>
    <string>Main</string>
    <key>UISupportedInterfaceOrientations</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
    </array>
    <key>UISupportedInterfaceOrientations~ipad</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
    </array>
    <key>UIViewControllerBasedStatusBarAppearance</key>
    <false/>
    <key>io.flutter.embedded_views_preview</key>
    <true/>
</dict>
</plist>

Podfile

# Uncomment this line to define a global platform for your project
platform :ios, '10.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

project 'Runner', {
  'Debug' => :debug,
  'Profile' => :release,
  'Release' => :release,
}

def flutter_root
  generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
  unless File.exist?(generated_xcode_build_settings_path)
    raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
  end

  File.foreach(generated_xcode_build_settings_path) do |line|
    matches = line.match(/FLUTTER_ROOT\=(.*)/)
    return matches[1].strip if matches
  end
  raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end

require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)

flutter_ios_podfile_setup

target 'Runner' do
  use_frameworks!
  use_modular_headers!

  pod 'Kronos'
  pod 'Alamofire', '~> 4.5'

  flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))

end

post_install do |installer|
  installer.pods_project.build_configurations.each do |config|
    config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
  end
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)

    target.build_configurations.each do |config|
          # You can remove unused permissions here
          # for more infomation: https://github.com/BaseflowIT/flutter-permission-handler/blob/master/permission_handler/ios/Classes/PermissionHandlerEnums.h
          # e.g. when you don't need camera permission, just add 'PERMISSION_CAMERA=0'
          config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
            '$(inherited)',

            ## dart: PermissionGroup.calendar
            'PERMISSION_EVENTS=0',

            ## dart: PermissionGroup.reminders
            'PERMISSION_REMINDERS=0',

            ## dart: PermissionGroup.contacts
            'PERMISSION_CONTACTS=0',

            ## dart: PermissionGroup.camera
            'PERMISSION_CAMERA=1',

            ## dart: PermissionGroup.microphone
            'PERMISSION_MICROPHONE=0',

            ## dart: PermissionGroup.speech
            'PERMISSION_SPEECH_RECOGNIZER=0',

            ## dart: PermissionGroup.photos
            'PERMISSION_PHOTOS=1',

            ## dart: [PermissionGroup.location, PermissionGroup.locationAlways, PermissionGroup.locationWhenInUse]
            'PERMISSION_LOCATION=1',

            ## dart: PermissionGroup.notification
            'PERMISSION_NOTIFICATIONS=1',

            ## dart: PermissionGroup.mediaLibrary
            'PERMISSION_MEDIA_LIBRARY=1',

            ## dart: PermissionGroup.sensors
            'PERMISSION_SENSORS=0',

            ## dart: PermissionGroup.bluetooth
            'PERMISSION_BLUETOOTH=0',

            ## dart: PermissionGroup.appTrackingTransparency
            'PERMISSION_APP_TRACKING_TRANSPARENCY=0'
          ]

        end
  end
end
Mocaris commented 3 years ago

We have the same mistake @eldarkk

JDDV commented 3 years ago

@Mocaris and @eldarkk, this the same issue occur if you go back one version of the permission handler in the pub spec.yaml (version ^8.1.3)?

Also to make sure there is no caching problem try to run a flutter clean and then a flutter pub get to get the dependencies.

Mocaris commented 3 years ago

@JDDV

@Mocaris and @eldarkk, this the same issue occur if you go back one version of the permission handler in the pub spec.yaml (version ^8.1.3)?

Also to make sure there is no caching problem try to run a flutter clean and then a flutter pub get to get the dependencies.

There is no problem with the 8.1.3 version used yesterday, because I submitted the packaged version to TestFlight. This problem occurred after the 8.1.4 version was upgraded

Mocaris commented 3 years ago

@JDDV Thanks

JDDV commented 3 years ago

@Mocaris & @eldarkk, you can safely use the newest version which just is published (version ^8.1.4+1). There was a small bug where the code

else if (status != PermissionStatusDenied) {
        completionHandler(status);
    }

did not have a return; statement, so it would go further to the requestAlwaysAuthorization while the _permissionStatusHandler was already removed from the memory, resulting in the error as shown in your images. this is fixed now by adding a return; statement in the code.

This solved the problem for us, I will close this issue now but please feel free to comment again if it did not solve your problem!

WXXXXH commented 3 years ago

@Mocaris & @eldarkk,您可以安全地使用刚刚发布的最新版本(版本^8.1.4+1)。代码有一个小错误

else if (status != PermissionStatusDenied) {
        completionHandler(status);
    }

没有return;语句,所以当_permissionStatusHandler已经从内存中删除时,它会进一步转到requestAlwaysAuthorization,导致图像中显示的错误。现在通过在代码中添加return;语句来解决这个问题。

这为我们解决了问题,我现在将解决这个问题,但如果它没有解决您的问题,请随时再次发表评论!

image
JDDV commented 3 years ago

Hi @WXXXXH, Can you provide us with a bit more information? Like when does this error happen for you and which permission did you try to request before getting this error?

Can you provide a small minimal reproduction code snippet so I can see where this error is coming from?

Thanks in advance!