[firebase_core] Firebase.initializeApp with demoProjectId crashes on iOS with SIGABRT (FIRInstallations validateAPIKey) - Follow-up to locked #17788
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 22/100
Hướng nghiên cứu
Start in firebase_core/lib/src/firebase.dart, where demoProjectId builds the FirebaseOptions with the hardcoded apiKey '12345'. Reproduce with the linked repro project on an iOS simulator to see the SIGABRT from FIRInstallations validateAPIKey. Pull request #18792 already targets this, so check it before starting. Done means the demo options pass validation on Apple platforms and the repro app launches without crashing.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Description
This is a follow-up to locked issue #17788. I have created a clean, minimal reproduction project with no remote Firebase project, no GoogleService-Info.plist, and no google-services.json:
👉 Reproduction Repository: https://github.com/akurnaz/flutterfire_repro
The issue is that Firebase.initializeApp(demoProjectId: '...') crashes natively on iOS (EXC_CRASH (SIGABRT) / Abort trap: 6) as soon as any package that depends on FirebaseInstallations (e.g., firebase_crashlytics, firebase_auth, or firebase_messaging) is present.
Steps to Reproduce
- Clone the reproduction repo:
git clone https://github.com/akurnaz/flutterfire_repro.git - Run on an iOS Simulator:
flutter run - The application crashes immediately on startup.
Alternatively, in any fresh Flutter app:
- Add
firebase_core: ^4.15.0andfirebase_crashlytics: ^5.4.0(which pulls inFirebaseInstallations). - Call
await Firebase.initializeApp(demoProjectId: 'demo-template');inmain().
Crash Stack Trace
Termination: SIGNAL (Abort trap: 6 / SIGABRT)
CoreFoundation - __exceptionPreprocess
libobjc.A.dylib - objc_exception_throw
Runner - +[FIRInstallations validateAPIKey:]
Runner - +[FIRInstallations validateAppOptions:appName:]
Runner - -[FIRInstallations initWithAppOptions:appName:installationsIDController:prefetchAuthToken:]
Runner - -[FIRInstallations initWithApp:]
Runner - __40+[FIRInstallations componentsToRegister]_block_invoke
Runner - -[FIRComponentContainer instantiateInstanceForProtocol:withBlock:]
Runner - -[FIRComponentContainer instanceForProtocol:]
Runner - -[FIRComponentContainer instantiateEagerComponents]
Runner - +[FIRApp configureWithName:options:]
Runner - FLTFirebaseCorePlugin.initializeApp(appName:initializeAppRequest:completion:)
Root Cause
- In
firebase_core/lib/src/firebase.dart,demoProjectIdsets a hardcoded dummy API key:
resolvedOptions = FirebaseOptions(
apiKey: '12345',
appId: '1:1:$platformString:1',
messagingSenderId: '',
projectId: demoProjectId,
);
- In the iOS native SDK (
firebase-ios-sdk),FIRInstallations.mstrictly validates that the API key is 39 characters and begins withA:
+ (void)validateAPIKey:(nullable NSString *)APIKey {
if (APIKey.length != kExpectedAPIKeyLength) { // kExpectedAPIKeyLength = 39
[validationIssues addObject:@"API Key length must be 39 characters"];
}
if (![[APIKey substringToIndex:1] isEqualToString:@"A"]) {
[validationIssues addObject:@"API Key must start with `A`"];
}
if (validationIssues.count > 0) {
[NSException raise:kFirebaseInstallationsErrorDomain format:...];
}
}
- Because
'12345'fails this validation, an uncaughtNSExceptionis thrown, resulting in an uncatchableSIGABRTcrash on iOS.
Suggested Fix
In firebase_core/lib/src/firebase.dart, format the dummy apiKey to be a 39-character string starting with A on Apple platforms:
apiKey: (defaultTargetPlatform == TargetPlatform.iOS || defaultTargetPlatform == TargetPlatform.macOS)
? 'AIzaSy0000000000000000000000000000000'
: '12345',
- Ngôn ngữ chính
- Dart
- Star
- 9.3k
- Fork
- 4.1k
- Merge trung bình
- 2 ngày 8 giờ
- Pull request đã merge (30 ngày)
- 46
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của firebase/flutterfire
-
[firebase_auth]: authStateChanges() never emits null when the user is force-signed-out before the stream is listened to (iOS, macOS, Android)Có thể đã có người làm @JulianPscheid đã nhận 2 ngày trước. Đang mởNeeds Attention platform: android platform: ios platform: macos plugin: auth reproduced type: bug
Độ khó 4/5 1-2 ngày Mức phù hợp với người mới 15/100
firebase/flutterfire#18796 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
blocked: customer-response Needs Attention platform: ios plugin: messaging type: bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
firebase/flutterfire#18776 · 4 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[📚] Remote Config Windows Support still N/A on ReadmeCó thể đã có người làm @nightcityblade đã nhận 7 ngày trước. Đang mởblocked: customer-response good first issue Needs Attention platform: windows plugin: remote_config type: documentation
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 30/100
firebase/flutterfire#18763 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[cloud_firestore]: a snapshots() listener cancelled while it registers is never removed nativelyCó thể đã có người làm @chiliec đã nhận 20 ngày trước. Đang mởNeeds Attention platform: android platform: ios platform: macos plugin: cloud_firestore reproduced type: bug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 72/100
firebase/flutterfire#18724 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[firebase_storage] Windows native crash in upload progress callback, sink ownership and thread dispatchCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mởblocked: flutter platform: windows plugin: storage reproduced type: bug
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
firebase/flutterfire#18664 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của firebase/flutterfire
Issue tương tự
-
Document supported hardwareĐang mởDocumentation
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Kazakh (kk_KZ) and Georgian (ka_GE) system locales get English instead of the shipped translationsĐang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 1 ngày
-
area: docs eco: dart good first issue help wanted lane: free-agent roadmap size: XS type: docs
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
arminazimi/evergreen#430 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area: rust-core bug priority: low
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug direct-code
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
aaronified/fluenough#526 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày