Skip to content

Make BackgroundIsolateBinaryMessenger API consistent on web #145260

Closed

Description

@ekuleshov

Use case

The BackgroundIsolateBinaryMessenger API requires an ensureInitialized() method call before its instance field can be used. Unfortunately the web implementation of the BackgroundIsolateBinaryMessenger does not have the ensureInitialized() method, to the compilation targeted for the web is failing at compile time with Member not found: 'BackgroundIsolateBinaryMessenger.ensureInitialized' error.

Currently we have to make own wrapper with platform-specific import to make this compile on web.

Proposal

It would be really handy if BackgroundIsolateBinaryMessenger has consistent API between io and web implementations. It will be sufficient to have it throw UnsupportedError('Isolates not supported on web.')

Activity

  1. darshankawar commented on Mar 18, 2024

    @darshankawar
    Member

    @ekuleshov
    Please check this and see if it helps in your case or not.

  2. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Mar 18, 2024
  3. ekuleshov commented on Mar 18, 2024

    @ekuleshov
    Author

    @ekuleshov Please check this and see if it helps in your case or not.

    Essentially that is the same issue looked from a different angle. But the solution I'm suggesting/requesting here is much simpler and does not require changes in the Dart compiler.

    There is already conditional import in the Flutter's package:flutter/services.dart which imports one of:

    • _background_isolate_binary_messenger_io.dart
    • _background_isolate_binary_messenger_web.dart

    However, due to the asymmetry of the web API (i.e. absence of the ensureInitialized() in the web-specific implementation), in order to use the web version adding if(kIsWeb) ... is not enough as noted in #136886

    We have to make own wrapper with our own conditional import and implement own wrappers for ensureInitialized() for io and web.

    If the Flutter's _background_isolate_binary_messenger_web.dart implementation simply had an ensureInitialized() method matching the io's API, all of that won't be necessary and we could simply use if(kIsWeb) ... instead of all those custom wrappers.

  4. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Mar 18, 2024
  5. darshankawar commented on Mar 19, 2024

    @darshankawar
    Member

    Thanks for the feedback.

  6. added
    c: new featureNothing broken; request for a new capability
    platform-webWeb applications specifically
    c: proposalA detailed proposal for a change to Flutter
    team-webOwned by Web platform team
    and removed
    in triagePresently being triaged by the triage team
    on Mar 19, 2024
  7. added
    P2Important issues not at the top of the work list
    triaged-webTriaged by Web platform team
    on Mar 21, 2024
  8. added
    P1High-priority issues at the top of the work list
    and removed
    P2Important issues not at the top of the work list
    on Mar 21, 2024
  9. ditman commented on Mar 23, 2024

    @ditman
    Member

    I'll work on adding this method next, it'll throw Unimplemented (or Unsupported, as requested by OP!)

  10. added
    r: fixedIssue is closed as already fixed in a newer version
    on Mar 27, 2024
  11. github-actions commented on Apr 10, 2024

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  12. locked as resolved and limited conversation to collaborators on Apr 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P1High-priority issues at the top of the work listc: new featureNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to Flutterplatform-webWeb applications specificallyr: fixedIssue is closed as already fixed in a newer versionteam-webOwned by Web platform teamtriaged-webTriaged by Web platform team

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions