Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Thread 1: EXC_BAD_ACCESS (code=2, address=0x16ba47fd0) #64

Closed
balaji-sasikumar opened this issue Aug 7, 2023 · 13 comments · Fixed by #69
Closed

Thread 1: EXC_BAD_ACCESS (code=2, address=0x16ba47fd0) #64

balaji-sasikumar opened this issue Aug 7, 2023 · 13 comments · Fixed by #69
Labels
bug/fix Something isn't working platform: ios iOS platform

Comments

@balaji-sasikumar
Copy link

balaji-sasikumar commented Aug 7, 2023

Plugin version:

"@capacitor-community/privacy-screen": "^4.1.1",

Platform(s):

in ios

Current behavior:

The app crashes with the "EXC_BAD_ACCESS" error as described above when certain events related to the "privacy-screen" package occur.

Expected behavior
The app should operate smoothly without any crashes or errors after installing the "@capacitor-community/privacy-screen" package.

Steps to reproduce:

1.Install the "@capacitor-community/privacy-screen" package in the project using npm or yarn.
2.Integrate the package into the app according to the documentation provided by the package.
3.Run the app on a device or simulator.
4.Perform actions that trigger the events related to the "privacy-screen" package, such as going to the background or returning to the foreground.

Capacitor doctor:

💊 Capacitor Doctor 💊

Latest Dependencies:

@capacitor/cli: 5.2.2
@capacitor/core: 5.2.2
@capacitor/android: 5.2.2
@capacitor/ios: 5.2.2

Installed Dependencies:

@capacitor/cli: 4.8.1
@capacitor/android: 4.8.1
@capacitor/core: 4.8.1
@capacitor/ios: 4.8.1

[success] iOS looking great! 👌
[success] Android looking great!

@robingenz
Copy link
Member

Thank you for your request.
Please provide a Minimal, Reproducible Example using this template in a public GitHub repository so I can debug the issue.

@balaji-sasikumar
Copy link
Author

balaji-sasikumar commented Aug 7, 2023

After installing the "@capacitor-community/privacy-screen" package and following the provided steps to enable it in the "capacitor.config.json" and "capacitor.config.ts" files, I built the app and installed it on my iPhone 13 Pro. However, as soon as I put the app into the background by pressing the home button or switching to another app, the app crashed with the "Thread 1: EXC_BAD_ACCESS" exception in the "AppDelegate.swift" file at the line where the class is defined:

class AppDelegate: UIResponder, UIApplicationDelegate {

exception-privacy-screen

This issue occurred consistently after enabling the "PrivacyScreen" plugin, and I couldn't find any direct cause for the crash. I checked for any conflicts with other plugins or native code, but the crash seemed to be isolated to the "PrivacyScreen" plugin.

As this exception significantly impacts the stability of the app, I kindly request support from the community to investigate the root cause and find a resolution. I am willing to provide any additional information or logs required for debugging purposes. Any assistance in resolving this critical issue would be highly appreciated. Thank you.

@robingenz
Copy link
Member

As i said, please provide a Minimal, Reproducible Example using this template in a public GitHub repository so I can debug the issue.

@ArbiCap-Jordy
Copy link

ArbiCap-Jordy commented Aug 7, 2023

Got exactly the same problem and tried in a fresh project, same issue.

package.json

{
"name": "fresh",
"version": "0.0.1",
"author": "Ionic Framework",
"homepage": "https://ionicframework.com/",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"watch": "ng build --watch --configuration development",
"test": "ng test",
"lint": "ng lint"
},
"private": true,
"dependencies": {
"@angular/animations": "^16.0.0",
"@angular/common": "^16.0.0",
"@angular/compiler": "^16.0.0",
"@angular/core": "^16.0.0",
"@angular/forms": "^16.0.0",
"@angular/platform-browser": "^16.0.0",
"@angular/platform-browser-dynamic": "^16.0.0",
"@angular/router": "^16.0.0",
"@capacitor-community/privacy-screen": "^4.1.1",
"@capacitor/app": "5.0.6",
"@capacitor/core": "5.2.2",
"@capacitor/haptics": "5.0.6",
"@capacitor/ios": "5.2.2",
"@capacitor/keyboard": "5.0.6",
"@capacitor/status-bar": "5.0.6",
"@ionic/angular": "^7.0.0",
"ionicons": "^7.0.0",
"rxjs": "~7.8.0",
"tslib": "^2.3.0",
"zone.js": "~0.13.0"
},
"devDependencies": {
"@angular-devkit/build-angular": "^16.0.0",
"@angular-eslint/builder": "^16.0.0",
"@angular-eslint/eslint-plugin": "^16.0.0",
"@angular-eslint/eslint-plugin-template": "^16.0.0",
"@angular-eslint/schematics": "^16.0.0",
"@angular-eslint/template-parser": "^16.0.0",
"@angular/cli": "^16.0.0",
"@angular/compiler": "^16.0.0",
"@angular/compiler-cli": "^16.0.0",
"@angular/language-service": "^16.0.0",
"@capacitor/cli": "5.2.2",
"@ionic/angular-toolkit": "^9.0.0",
"@types/jasmine": "~4.3.0",
"@types/node": "^12.11.1",
"@typescript-eslint/eslint-plugin": "5.3.0",
"@typescript-eslint/parser": "5.3.0",
"eslint": "^7.26.0",
"eslint-plugin-import": "2.22.1",
"eslint-plugin-jsdoc": "30.7.6",
"eslint-plugin-prefer-arrow": "1.2.2",
"jasmine-core": "~4.6.0",
"jasmine-spec-reporter": "~5.0.0",
"karma": "~6.4.0",
"karma-chrome-launcher": "~3.2.0",
"karma-coverage": "~2.2.0",
"karma-coverage-istanbul-reporter": "~3.0.2",
"karma-jasmine": "~5.1.0",
"karma-jasmine-html-reporter": "~2.0.0",
"ts-node": "^8.3.0",
"typescript": "~5.0.2"
},
"description": "An Ionic project"
}

The only thing I did here is to enable the plugin in the app.component.ts

import { Component } from '@angular/core';
import { PrivacyScreen } from '@capacitor-community/privacy-screen';

@Component({
  selector: 'app-root',
  templateUrl: 'app.component.html',
  styleUrls: ['app.component.scss'],
})
export class AppComponent {
  constructor() {

  }

  initApp(){
    // ++++++++++++++++++++++++
    // Setup Privacy Screen
    // ++++++++++++++++++++++++
    PrivacyScreen.addListener('screenRecordingStarted', () => {
      // Your code to execute when the screen recording starts
    });
    PrivacyScreen.addListener('screenshotTaken', () => {
      // Your code to execute when the screen recording starts
    });
    PrivacyScreen.enable();
  }
}

@robingenz robingenz added platform: ios iOS platform and removed platform: android Android platform labels Aug 7, 2023
@saravanapriyanm
Copy link

We are also experiencing same issue.

@benluria
Copy link

benluria commented Aug 8, 2023

We are experiencing the same issue. Steps to reproduce:

  • Enable PrivacyScreen on a page
  • Put app in iphone background
  • After about 15-20 seconds, bring app to foreground
  • App restarts and sends crash notification. Xcode shows: EXC_BAD_ACCESS

@RishikeshB
Copy link

experiencing the same issue , while enable PrivacyScreen on a page and running the app on background within 8-10 sec the app crashed with the "Thread 1: EXC_BAD_ACCESS" exception in the "AppDelegate.swift"

@godhand1607
Copy link

godhand1607 commented Aug 11, 2023

++ also getting this error

UPDATE: It seems to only happen if PrivacyScreen is enabled at startup

@benluria
Copy link

benluria commented Aug 15, 2023

++ also getting this error

UPDATE: It seems to only happen if PrivacyScreen is enabled at startup

I am experiencing the crash and it is disabled in CapacitorConfig. It is only enabled on specific pages.
Example using Ionic Capacitor w/ Angular

capacitor.config.ts:

const config: CapacitorConfig = {
  plugins: {
    PrivacyScreen: {
      enable: false
    }
  }

component.ts file:

ionViewDidEnter() {
   if (Capacitor.isNativePlatform()) {
       PrivacyScreen.enable()
       .then(() => {
           console.log('privacy screen enabled');
       })
       .catch(err => console.error(err));
   }
 }

@ArbiCap-Jordy
Copy link

++ also getting this error

UPDATE: It seems to only happen if PrivacyScreen is enabled at startup

I tried this way and it was working for a while, but the crashes actually continue. It doesn't seem to solve the problem

@robingenz
Copy link
Member

robingenz commented Sep 2, 2023

This issue is caused by the disable screenshots feature (see #59).
Version 4.0.0 works.
@dtarnawsky Any idea?

EDIT: Interesting fact: It works without problems if you enable the plugin twice (see #65).

@dtarnawsky
Copy link
Contributor

Not sure why it is functioning this way now but adding 2 secure text fields seems to fix the problem so I've done that in the PR: #69

@robingenz
Copy link
Member

Thanks @dtarnawsky! I will publish a new release.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug/fix Something isn't working platform: ios iOS platform
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants