Skip to content

Flutter web - Failed to obtain exclusive access to the persistence layer when initialised with synchronizeTabs: true #6792

Closed
@pldelattre

Description

@pldelattre

[REQUIRED] Describe your environment

  • Operating System version: MacOs Monterey 12.6.1
  • Browser version: Chrome 107.0.5304.110 and Safari 16.1
  • Firebase SDK version: 9.11
  • Firebase Product: firestore

[REQUIRED] Describe the problem

I have built a flutter web app with persistence enabled and synchronizeTabs: true.
It works when opening the first chrome tab but it fails when loading the app on another tab with the following error in chrome console.

@firebase/firestore: Firestore (9.11.0): Error enabling offline persistence. Falling back to persistence disabled: FirebaseError: [code=failed-precondition]: Failed to obtain exclusive access to the persistence layer. To allow shared access, multi-tab synchronization has to be enabled in all tabs. If you are using experimentalForceOwningTab:true, make sure that only one tab has persistence enabled at any given time.

flutter packages

  firebase_core: ^2.2.0
  firebase_auth: ^4.1.2
  cloud_firestore: ^4.0.5
  firebase_storage: ^11.0.5

Flutter code to reproduce:

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp(
    options: DefaultFirebaseOptions.currentPlatform,
  );
 
  if (kIsWeb) {
    await FirebaseFirestore.instance
        .enablePersistence(const PersistenceSettings(synchronizeTabs: true));
  }

  runApp(const MyApp());
}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions