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

Crash in [APMMeasurement fetchRemoteConfig] #12614

Closed
eparis-bit opened this issue Mar 22, 2024 · 9 comments
Closed

Crash in [APMMeasurement fetchRemoteConfig] #12614

eparis-bit opened this issue Mar 22, 2024 · 9 comments
Assignees

Comments

@eparis-bit
Copy link

Description

App crash at first startup after fresh install, after a few seconds. The stack trace indicate a crash when APMMeasurement calls [NSString(Bit) isBitEnabledAtIndex:]:

Fatal Exception: NSInvalidArgumentException
-[__NSCFConstantString characterAtIndex:]: Range or index out of bounds

0 CoreFoundation 0xec678 (Missing UUID 5a6c1f41bf7032f6a1d65b894dd21362)
1 libobjc.A.dylib 0x2bc80 objc_exception_throw
2 CoreFoundation 0x1b4cbc (Missing UUID 5a6c1f41bf7032f6a1d65b894dd21362)
3 CoreFoundation 0x1b4cf4 (Missing UUID 5a6c1f41bf7032f6a1d65b894dd21362)
4 CoreFoundation 0x381b4 (Missing UUID 5a6c1f41bf7032f6a1d65b894dd21362)
5 Bandsintown Concerts 0x18fdb90 -[NSString(Bit) isBitEnabledAtIndex:]
6 Bandsintown Concerts 0x18f9c94 -[APMTCFClient stringRepresentationFromTCFData]
7 Bandsintown Concerts 0x18f9ea0 -[APMTCFClient persistedValuesEqualCurrentData]
8 Bandsintown Concerts 0x18f974c -[APMTCFClient setConsentFromTCFData]
9 Bandsintown Concerts 0x18a1f68 -[APMMeasurement tcfClientSetConsentFromData]
10 Bandsintown Concerts 0x1899dd0 -[APMMeasurement uploadData]
11 Bandsintown Concerts 0x18a0d30 -[APMMeasurement networkRemoteConfigFetchCompletionHandler:data:error:]
12 Bandsintown Concerts 0x18a0668 __35-[APMMeasurement fetchRemoteConfig]_block_invoke
13 libdispatch.dylib 0x26a8 (Missing UUID c49a5fc2c87339139603004f5d0175e7)
14 libdispatch.dylib 0x4300 (Missing UUID c49a5fc2c87339139603004f5d0175e7)
...

Screenshot 2024-03-22 at 10 42 43 AM

Reproducing the issue

No response

Firebase SDK Version

10.23.0

Xcode Version

15.2

Installation Method

Swift Package Manager

Firebase Product(s)

Analytics

Targeted Platforms

iOS

Relevant Log Output

No response

If using Swift Package Manager, the project's Package.resolved

Expand Package.resolved snippet
    {
      "identity" : "firebase-ios-sdk",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/firebase/firebase-ios-sdk",
      "state" : {
        "revision" : "fcf5ced6dae2d43fced2581e673cc3b59bdb8ffa",
        "version" : "10.23.0"
      }
    }

If using CocoaPods, the project's Podfile.lock

Expand Podfile.lock snippet
Replace this line with the contents of your Podfile.lock!
@google-oss-bot
Copy link

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

@CWftw
Copy link

CWftw commented Mar 24, 2024

Seeing this as well after updating Firebase pods to 10.23.0

@rizafran
Copy link
Contributor

Thanks for reporting. I tried to reproduce the issue but I'm unable to get the same error. Is it possible for you to provide a reproducible example?

@pcfba pcfba self-assigned this Mar 25, 2024
@eparis-bit
Copy link
Author

I tried a different things that could help fix the issue.

First I tried downgrading to Firebase 10.22.1 / GoogleAppMeasurement 10.22.1 => no crash

Then I updated back to Firebase 10.23.0 / GoogleAppMeasurement 10.23.0 => crash on first app launch

Second, I swizzled the method [NSString isBitEnabledAtIndex:] to intercept the calls to this method and to inspect the arguments: that method is call with self = empty string @"" and index = 754. It raised an exception and crash the app.
Curiously at the second run, it also raised an exception but it's catched and that line is output in the console:

10.23.0 - [FirebaseAnalytics][I-ACS030000] Exception on worker queue. Block ID=APMMeasurement:1771. Exception: 0x00000001039e7590 -[APMTCFClient: -[__NSCFConstantString characterAtIndex:]: Range or index out of bounds

It looks like that method is called when parsing the protobuf response of that http request:

https://app-analytics-services.com/config/app/1:826312950607:ios:18cdd083d09049a7?platform=ios&runtime_version=0&gmp_version=102300

Maybe I have some usual configs in my app on Firebase.

My workaround to prevent the crash:

// Woraround bug in GoogleAppMeasurement framework 10.23.0
// see: https://github.com/firebase/firebase-ios-sdk/issues/12614

@interface NSString (Bit)

- (BOOL)isBitEnabledAtIndex:(NSInteger)index;

@end

@implementation NSString (Swizzled)

- (BOOL)swizzleIsBitEnabledAtIndex:(NSInteger)index
{
    if ([self length] < index) {
        return NO;
    }
    return [self swizzleIsBitEnabledAtIndex:index];
}

@end

...
    MethodSwizzle([NSString class], @selector(isBitEnabledAtIndex:), @selector(swizzleIsBitEnabledAtIndex:));
...

@pcfba
Copy link
Contributor

pcfba commented Mar 25, 2024

Thanks for the report. We have a fix for this crash that will go out in the next release.

@pcfba
Copy link
Contributor

pcfba commented Mar 25, 2024

Internal tracking bug b/331256683.

@paulb777 paulb777 added this to the 10.24.0 - M146 milestone Mar 25, 2024
@htcgh
Copy link
Member

htcgh commented Mar 28, 2024

Firebase 10.23.1 was just released, which includes the fix for this issue.

@htcgh htcgh closed this as completed Mar 28, 2024
@asifmohd
Copy link

asifmohd commented Apr 2, 2024

@paulb777 @htcgh Would it be possible for the team to please upload a Firebase.zip (which contains all Firebase xcframeworks) file in the release section for this patch release?

@paulb777
Copy link
Member

paulb777 commented Apr 2, 2024

Sorry, we're not able to generate a Firebase.zip for this patch release. The fix will be available in the 10.24.0 zip due out next week.

In the meantime, the 10.23.1 binaries can be extracted from the CocoaPods or Swift Package Manager releases.

@firebase firebase locked and limited conversation to collaborators Apr 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

8 participants