Skip to content

[Bug] OnMessage(firebase::messaging::Message const&) SIGSEGV #1686

Open
@shokarta

Description

@shokarta

[REQUIRED] Please fill in the following fields:

  • Pre-built SDK from the website or open-source from this repo: 12.5.0
  • Firebase C++ SDK version: above
  • Problematic Firebase Component: Messaging
  • Other Firebase Components in use: Analytics, Crashlytics
  • Platform you are using the C++ SDK on: Windows 11
  • Platform you are targeting: Android

[REQUIRED] Please describe the issue here:

Users reporting crash when clicking on notification which opens the app and crashes immidiately.
Crashlytics says:

        null pointer dereference: SIGSEGV  0x0000000000000000
#00 pc 0x556cf8 libfilmtoroMobile_arm64-v8a.so (FirebaseQtMessagingPrivate::OnMessage(firebase::messaging::Message const&)) (BuildId: 43a256109b3156cbc5e205c347ead0122f3a23a8)
#01 pc 0x556cf0 libfilmtoroMobile_arm64-v8a.so (FirebaseQtMessagingPrivate::OnMessage(firebase::messaging::Message const&)) (BuildId: 43a256109b3156cbc5e205c347ead0122f3a23a8)
#02 pc 0x7b0294 libfilmtoroMobile_arm64-v8a.so (firebase::messaging::NotifyListenerOnMessage(firebase::messaging::Message const&) [common.cc:124]) (BuildId: 43a256109b3156cbc5e205c347ead0122f3a23a8)
#03 pc 0x7b35ec libfilmtoroMobile_arm64-v8a.so (firebase::messaging::ProcessMessages() [messaging.cc:547]) (BuildId: 43a256109b3156cbc5e205c347ead0122f3a23a8)
#04 pc 0x7b41fc libfilmtoroMobile_arm64-v8a.so (firebase::messaging::MessageProcessingThread(void*) [messaging.cc:367]) (BuildId: 43a256109b3156cbc5e205c347ead0122f3a23a8)
#05 pc 0xfd254 libc.so (BuildId: 8aaf102cfbdac2f120bf95c648547386)
#06 pc 0x96a04 libc.so (BuildId: 8aaf102cfbdac2f120bf95c648547386)

Affected devices:

  • Samsung Galaxy S20+ - Android 13
  • Samsung Galasy S24 - Android 14
  • Samsubg Galaxy S23 Ultra - Android 14
  • Vivo X200 Pro - Android 15

Steps to reproduce:

My devices or simulator does not crash

Relevant Code:

Build.gradle:

buildscript {
    repositories {
        google()
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:8.6.0'							// Notice the 8.6 version here, not sure why but seems we always need to be one version less than what we updated
		classpath 'com.google.gms:google-services:4.4.2'							// Google Services plugin
		classpath 'com.google.firebase:firebase-crashlytics-gradle:3.0.2'           // Crashlytics
		
		def firebase_cpp_sdk_dir = System.getProperty('firebase_cpp_sdk.dir')		// the lines below won't need to be changed later as the path is read from gradle.properties
		
		gradle.ext.firebase_cpp_sdk_dir = "$firebase_cpp_sdk_dir"
        apply from: "$firebase_cpp_sdk_dir/Android/firebase_dependencies.gradle"
	}
}

repositories {
    google()
    mavenCentral()
}

apply plugin: qtGradlePluginType
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'										// Google Services plugin
apply plugin: 'com.google.firebase.crashlytics'										// Crashlytics


dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
    implementation 'androidx.core:core:1.13.1'

	implementation(platform("com.google.firebase:firebase-bom:33.7.0"))				// Import the BoM for the Firebase platform
	implementation("com.google.firebase:firebase-crashlytics")						// Crashlytics			19.4.0
	implementation("com.google.firebase:firebase-crashlytics-ndk")					// Crashlytics NDK		19.4.0
	implementation("com.google.firebase:firebase-analytics")						// Not sure if this is needed when Analytics is loaded via c++ sdk (end of this file)		22.2.0
}

android {
    /*******************************************************
     * The following variables:
     * - androidBuildToolsVersion,
     * - androidCompileSdkVersion
     * - qtAndroidDir - holds the path to qt android files
     *                   needed to build any Qt application
     *                   on Android.
     * - qtGradlePluginType - whether to build an app or a library
     *
     * are defined in gradle.properties file. This file is
     * updated by QtCreator and androiddeployqt tools.
     * Changing them manually might break the compilation!
     *******************************************************/

    namespace androidPackageName
    compileSdkVersion androidCompileSdkVersion
    buildToolsVersion androidBuildToolsVersion
    ndkVersion androidNdkVersion

	packagingOptions {
        jniLibs {
			useLegacyPackaging true					// Extract native libraries from the APK
            keepDebugSymbols += '**/*.so'			// unstripped version
        }    
    }

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = [qtAndroidDir + '/src', 'src', 'java']
            aidl.srcDirs = [qtAndroidDir + '/src', 'src', 'aidl']
            res.srcDirs = [qtAndroidDir + '/res', 'res']
            resources.srcDirs = ['resources']
            renderscript.srcDirs = ['src']
            assets.srcDirs = ['assets']
            jniLibs.srcDirs = ['libs']
       }
    }

    tasks.withType(JavaCompile) {
        options.incremental = true
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    lintOptions {
        abortOnError false
    }

    // Do not compress Qt binary resources file
    aaptOptions {
        noCompress 'rcc'
    }

    defaultConfig {
        resConfig "en"
        minSdkVersion qtMinSdkVersion
        targetSdkVersion qtTargetSdkVersion
        ndk.abiFilters = qtTargetAbiList.split(",")
		ndk.debugSymbolLevel "FULL"
    }
	
	buildTypes {
		debug {
			// When minifyEnabled is set to true, Crashlytics automatically uploads mapping files because the plugin detects that obfuscation is enabled. mappingFileUploadEnabled defaults to true if minifyEnabled is true.
			//minifyEnabled true				// causes app crash on startup
			//shrinkResources true				// this should fix crash above, but doesnt
			//ndk {								// this should also fix crash above, but doesnt
			//	abiFilters "armeabi-v7a", "arm64-v8a", "x86", "x86_64"
			//}
			firebaseCrashlytics {
//				mappingFileUploadEnabled true			// true is automaticaly if minifyEnabled is set to true, however when enabled it does not upload anything to firebase console

				// Enable processing and uploading of native symbols to Crashlytics servers. By default, this is disabled to improve build speeds. This flag must be enabled to see properly-symbolicated native stack traces in the Crashlytics dashboard.
				nativeSymbolUploadEnabled false
//				unstrippedNativeLibsDir file("$buildDir/intermediates/merged_native_libs/debug/mergeDebugNativeLibs/out/lib/x86_64")				// when active, it does not upload anything to firebase console
			}
		}
		release {
			// When minifyEnabled is set to true, Crashlytics automatically uploads mapping files because the plugin detects that obfuscation is enabled. mappingFileUploadEnabled defaults to true if minifyEnabled is true.
			//minifyEnabled true				// causes app crash on startup
			//shrinkResources true				// this should fix crash above, but doesnt
			//ndk {								// this should also fix crash above, but doesnt
			//	abiFilters "armeabi-v7a", "arm64-v8a", "x86", "x86_64"
			//}
			firebaseCrashlytics {
//				mappingFileUploadEnabled true			// true is automaticaly if minifyEnabled is set to true, however when enabled it does not upload anything to firebase console

				// Enable processing and uploading of native symbols to Crashlytics servers. By default, this is disabled to improve build speeds. This flag must be enabled to see properly-symbolicated native stack traces in the Crashlytics dashboard.
				nativeSymbolUploadEnabled true
//				unstrippedNativeLibsDir file("$buildDir/intermediates/merged_native_libs/release/mergeReleaseNativeLibs/out/lib/arm64-v8a")			// when active, it does not upload anything to firebase console
			}
		}
	}
}


// You must put here all modules you want from firebase
firebaseCpp.dependencies {
    analytics
    messaging
}

AndroidManifest.xml:

<?xml version="1.0"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.filmtoro.appMobile" android:installLocation="auto" android:versionCode="-- %%INSERT_VERSION_CODE%% --" android:versionName="-- %%INSERT_VERSION_NAME%% --">

	<!-- %%INSERT_PERMISSIONS -->
		<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
		<uses-permission android:name="android.permission.INTERNET"/>
		<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
		<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

		<!-- Devices running Android 12L (API level 32) or lower  -->
		<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="32"/>

		<!-- Devices running Android 13 (API level 33) or higher -->
		<uses-permission android:name="android.permission.READ_MEDIA_IMAGES"/>
		<uses-permission android:name="android.permission.READ_MEDIA_VIDEO"/>

		<!-- To handle the reselection within the app on devices running Android 14
			 or higher if your app targets Android 14 (API level 34) or higher.  -->
		<uses-permission android:name="android.permission.READ_MEDIA_VISUAL_USER_SELECTED"/>

		<!-- Devices running Android 13 (API level 33) must allow push notifications -->
		<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>

		<!-- Firebase -->
		<uses-permission android:name="android.permission.WAKE_LOCK"/>
		<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/>
		<uses-permission android:name="${applicationId}.permission.C2D_MESSAGE"/>
		<permission android:name="${applicationId}.permission.C2D_MESSAGE" android:protectionLevel="signature"/>
		<uses-permission android:name="com.google.android.gms.permission.AD_ID"/>
	<!-- %%INSERT_PERMISSIONS -->

	<supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:smallScreens="true"/>

	<application android:name="org.qtproject.qt.android.bindings.QtApplication" android:hardwareAccelerated="true" android:label="Filmtoro" android:requestLegacyExternalStorage="true" android:allowNativeHeapPointerTagging="false" android:allowBackup="true" android:fullBackupOnly="false" android:enableOnBackInvokedCallback="false" android:extractNativeLibs="true" android:icon="@drawable/ic_launcher">

		<activity android:name="org.qtproject.qt.android.bindings.QtActivity" android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation|mcc|mnc|density" android:launchMode="singleTop" android:screenOrientation="portrait" android:exported="true" android:windowSoftInputMode="stateUnspecified|adjustUnspecified" android:theme="@style/splashScreenTheme" android:label="Filmtoro">
			<intent-filter>
				<action android:name="android.intent.action.MAIN"/>
				<category android:name="android.intent.category.LAUNCHER"/>
			</intent-filter>
			<intent-filter>
				<action android:name="com.google.firebase.MESSAGING_EVENT"/>
			</intent-filter>
			<meta-data android:name="android.app.lib_name" android:value="-- %%INSERT_APP_LIB_NAME%% --"/>
			<meta-data android:name="android.app.arguments" android:value="-- %%INSERT_APP_ARGUMENTS%% --"/>
			<!-- Used to specify custom system library path to run with local system libs -->
			<!-- <meta-data android:name="android.app.system_libs_prefix" android:value="/system/lib/" /> -->
			<!-- Messages maps -->
			<!-- <meta-data android:value="@string/unsupported_android_version" android:name="android.app.unsupported_android_version"/> -->
			<!-- Messages maps -->
			<!-- Splash screen -->
			<!-- Orientation-specific (portrait/landscape) data is checked first. If not available for current orientation,
				 then android.app.splash_screen_drawable. For best results, use together with splash_screen_sticky and
				 use hideSplashScreen() with a fade-out animation from Qt Android Extras to hide the splash screen when you
				 are done populating your window with content. -->
			<meta-data android:name="android.app.splash_screen_drawable" android:resource="@drawable/splashscreen"/>
			<!-- meta-data android:name="android.app.splash_screen_drawable_portrait" android:resource="@drawable/logo_portrait" / -->
			<!-- meta-data android:name="android.app.splash_screen_drawable_landscape" android:resource="@drawable/logo_landscape" / -->
			<!-- <meta-data android:name="android.app.splash_screen_sticky" android:value="true" /> -->
			<!-- Splash screen -->
			<!-- Background running -->
			<!-- Warning: changing this value to true may cause unexpected crashes if the
						  application still try to draw after
						  "applicationStateChanged(Qt::ApplicationSuspended)"
						  signal is sent! -->
			<meta-data android:name="android.app.background_running" android:value="false"/>
			<!-- Background running -->
			<!-- auto screen scale factor -->
			<meta-data android:name="android.app.auto_screen_scale_factor" android:value="false"/>
			<!-- auto screen scale factor -->
			<!-- extract android style -->
			<!-- available android:values :
				* default - In most cases this will be the same as "full", but it can also be something else if needed, e.g., for compatibility reasons
				* full - useful QWidget & Quick Controls 1 apps
				* minimal - useful for Quick Controls 2 apps, it is much faster than "full"
				* none - useful for apps that don't use any of the above Qt modules
				-->
			<meta-data android:name="android.app.extract_android_style" android:value="minimal"/>
			<!-- extract android style -->
			<meta-data android:name="android.app.splash_screen_drawable" android:resource="@drawable/splashscreen"/>
		</activity>

		<!-- For adding service(s) please check: https://wiki.qt.io/AndroidServices -->
		<service android:name="com.google.firebase.messaging.cpp.ListenerService" android:exported="true">
			<intent-filter>
				<action android:name="com.google.firebase.MESSAGING_EVENT"/>
			</intent-filter>
		</service>

		<service android:name="com.google.firebase.messaging.cpp.RegistrationIntentService" android:permission="android.permission.BIND_JOB_SERVICE" android:exported="true">
		</service>

		<!-- <provider android:name="androidx.core.content.FileProvider" android:authorities="${applicationId}.qtprovider" android:exported="false" android:grantUriPermissions="true"> -->
			<!-- <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/qtprovider_paths" /> -->
		<!-- </provider> -->

	</application>

</manifest>

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions