Skip to content

Add a "blacklisted methods" test #7166

Closed

Description

@tvolkert

The following async file I/O methods should never be called -- they create undue overhead in the async wiring required to accomplish them, and their corresponding sync versions require minimal overhead.

  • File.lastModified()
  • FileSystemEntity.isDirectory()
  • FileSystemEntity.isFile()
  • FileSystemEntity.isLink()
  • FileSystemEntity.type()
  • FileSystemEntity.exists()
  • FileSystemEntity.stat()

We should convert all existing uses of these methods (in flutter_tools - we don't use them in the framework) to use the sync versions, and we should add a test that ensures we don't re-introduce them. Over time, if any other such methods come up, we can just add them to this method blacklist.

@johnmccutchan

Activity

  1. added
    a: tests"flutter test", flutter_test, or one of our tests
    toolAffects the "flutter" command-line tool. See also t: labels.
    on Dec 6, 2016
  2. tvolkert commented on Dec 6, 2016

    @tvolkert
    ContributorAuthor
  3. added this to the milestone on Dec 6, 2016
  4. Hixie commented on Dec 6, 2016

    @Hixie
    Contributor

    We should definitely either always use one or always use the other.

    Having said that, some people use NFS, and NFS can take a long time to return from these calls...

  5. danrubel commented on Dec 8, 2016

    @danrubel
  6. johnmccutchan commented on Dec 8, 2016

    @johnmccutchan
    Contributor

    @danrubel nice!

  7. added a commit that references this issue on Feb 15, 2017
    7b8705f
  8. Hixie commented on Jan 8, 2018

    @Hixie
    Contributor

    I was running the linter over some code recently and ran into this lint.

    I'm not convinced this is actually a good idea. Won't these methods risk entirely locking up the app when run on networked file systems or file systems with bad disks?

  9. tvolkert commented on Jan 8, 2018

    @tvolkert
    ContributorAuthor

    They'll lock up the app to the extent that the syscalls hang (whereas with async, we could add a timeout). So bottom-line: yes.

    That said, for local disk access, what spawned this issue is that @johnmccutchan and I were seeing real slowdowns in the Flutter tool due to the use of these async ops (in loops, for instance) -- where converting to sync calls saved a few hundred milliseconds.

  10. Hixie commented on Jan 8, 2018

    @Hixie
    Contributor

    A difficult trade-off. We definitely have users on NFS, but we also have many users on local disks...

  11. github-actions commented on Aug 8, 2021

    @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 Aug 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    a: tests"flutter test", flutter_test, or one of our testsc: contributor-productivityTeam-specific productivity, code health, technical debt.toolAffects the "flutter" command-line tool. See also t: labels.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions