fix(firestore,core,windows): per-engine BinaryMessenger, Firestore/Auth link order, Profile builds - #18516
Conversation
…th link order, Profile builds Three separate Windows bugs: - cloud_firestore stored its BinaryMessenger in a class-level static and reassigned it on every RegisterWithRegistrar, so in an app hosting several Flutter engines (e.g. desktop_multi_window) the last engine to register owned the messenger process-wide. Snapshot listeners opened from any other engine were delivered to the wrong isolate and silently never fired, and once that engine was destroyed the dangling pointer crashed the next snapshot call. The messenger is now a per-instance member threaded through the event channel builders. - cloud_firestore listed firebase_auth before firebase_firestore. MSVC resolves static libraries in link-line order and the SDK declares no dependency between the two imported targets, so apps using Firestore without Firebase Auth failed with an unresolved firebase::g_auth_initializer. - firebase_core patched IMPORTED_LOCATION only for DEBUG and RELEASE. The SDK never sets IMPORTED_CONFIGURATIONS, so every other configuration fell back to the Debug libraries. Flutter maps Profile's flags onto Release, so a Profile build compiled against the release CRT and linked debug-CRT libraries, failing on __imp__CrtDbgReport / __imp__invalid_parameter. Profile, RelWithDebInfo and MinSizeRel now resolve to the release libraries, and the windows e2e job gained a Profile build so it cannot regress.
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. |
Description
Fixes three Windows bugs.
1.
cloud_firestore'sBinaryMessengerwas a class-level static, reassigned on everyRegisterWithRegistrar. In an app hosting several Flutter engines (e.g.desktop_multi_window), the last engine to register owned the messenger process-wide: snapshot listeners opened from any other engine were delivered to the wrong isolate and silently never fired, and once that engine was destroyed the dangling pointer crashed the next snapshot call. It is now a per-instance member, passed toRegisterEventChannel/RegisterEventChannelWithUUID.2.
firebase_authwas linked beforefirebase_firestore. MSVC resolves static libraries in link-line order and the SDK declares no dependency between the two imported targets, so Firestore'screate_credentials_provider_desktop.objfailed onunresolved external symbol "void * firebase::g_auth_initializer"unless the app also depended onfirebase_auth(which put the lib back on the line, later). Reordered. Kept incloud_firestore's ownCMakeLists.txtrather than on the imported target in Core, following #18498.3. Only
DEBUGandRELEASEhad anIMPORTED_LOCATION. The SDK never setsIMPORTED_CONFIGURATIONS, so every other configuration fell back to the Debug libraries. Flutter maps Profile's flags onto Release, so a Profile build compiled against the release CRT and linked debug-CRT libraries, failing on__imp__CrtDbgReport/__imp__invalid_parameter.PROFILE,RELWITHDEBINFOandMINSIZERELnow resolve to the release libraries — same class of bug as #18073, which fixed Release only. Thewindowsjob gained a--profilebuild so it cannot regress.Related Issues
flutter build windows --profilefails witherror LNK2001: unresolved external symbol __imp__invalid_parameter#12051Checklist
///).melos run analyze) does not report any problems on my PR.Breaking Change