When, why, and how to multithread in Flutter

แชร์
ฝัง
  • เผยแพร่เมื่อ 11 พ.ค. 2022
  • Every Flutter application is powered by at least one Dart isolate, and every Dart isolate is powered by an event loop. Knowing how these fundamental parts of the Dart runtime operate is key to knowing when and where to multithread in Flutter. Learn both theory and application from two Dart and Flutter experts.
    Speakers: Michael Thomsen, Michael Goderbauer
    Watch more:
    All Google I/O 2022 Sessions → goo.gle/IO22_AllSessions
    Flutter at I/O 2022 playlist → goo.gle/IO22_Flutter
    All Google I/O 2022 technical sessions → goo.gle/IO22_Sessions
    Subscribe to Flutter! → goo.gle/FlutterYT
    #GoogleIO
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น • 58

  • @tq_malhotra
    @tq_malhotra 2 ปีที่แล้ว +66

    Please also post a tutorial for running background processes in Flutter.

    • @johnryan4928
      @johnryan4928 2 ปีที่แล้ว +13

      For background processing on Android and iOS, we recommend the workmanager package: docs.flutter.dev/development/packages-and-plugins/happy-paths/recommended#background-processing-

    • @PaurakhSharma
      @PaurakhSharma 2 ปีที่แล้ว +3

      @@johnryan4928 Sadly it doesn't work in the web.

    • @arifmaul1690
      @arifmaul1690 2 ปีที่แล้ว

      Phone

  • @user-eh5wo8re3d
    @user-eh5wo8re3d 2 ปีที่แล้ว +77

    I think videos like this should definitely mention the current limitations of flutter.
    In this case, that flutter on web can not make use of isolates at this moment.
    Since flutter 3 claims production readiness across all platforms, the intuitive notion a viewer of this video will take away, is that this works on all platforms.
    Simply hinting at the limitations here could save a lot of time and head scratching

    • @miksen
      @miksen 2 ปีที่แล้ว +6

      Yes, unfortunately Flutter web doesn't currently support isolates. We'll get the documentation updated to make that a bit clearer.

    • @JaredHasson
      @JaredHasson 2 ปีที่แล้ว +4

      Many of the Google I/O Flutter videos show off features that are only available for the original platforms. Flutter web, desktop, and linux, are not fully supported, no matter what the Flutter 3 claims are.

    • @michaelthomsen6857
      @michaelthomsen6857 2 ปีที่แล้ว +21

      @@JaredHasson Isolates are supported on Android, iOS, Windows, Linux, macOS, and embedded. Yes, they are not supported on the web currently. We try our best to be as multi-platform as possible, but there are a lot of technology constraints that are beyond our control.
      I do agree though we could have done a better job mentioning the web limitation in this video. We'll try to take the feedback to heart for future content!

    • @dc5
      @dc5 ปีที่แล้ว

      Great video! Which of the 3 solutions would be the most appropriate for running dart on cloud run, allowing the most amount of concurrent calls on a single cloud run instance as possible?

    • @user-ge6yv3qi2n
      @user-ge6yv3qi2n 8 หลายเดือนก่อน

      @@michaelthomsen6857is this even possible to run tasks in several threads on web? thought that there is JS limitations makes this never gonna happen in web

  • @HerrHafiz
    @HerrHafiz 27 วันที่ผ่านมา

    very good explanation, thank you Flutter team.

  • @charithahithaishi9844
    @charithahithaishi9844 2 ปีที่แล้ว +4

    Nicely explain 👏🏻, thank you Flutter team.

  • @TreyHope
    @TreyHope ปีที่แล้ว

    Solid demonstration, thank you for sharing.

  • @hasansalim1868
    @hasansalim1868 ปีที่แล้ว +1

    a very useful topics explained in a clear and nice way

  • @amansingh.h716
    @amansingh.h716 2 ปีที่แล้ว +3

    very good explanation

  • @fredgotpub871
    @fredgotpub871 2 ปีที่แล้ว +1

    Very lear with good examples !

  • @Raimkhodzhanov
    @Raimkhodzhanov 2 ปีที่แล้ว +2

    Thank You! Very helpful and interesting content!

    • @flutterdev
      @flutterdev  ปีที่แล้ว

      We appreciate the wonderful feedback, Raim! Glad to hear it's been helpful for you!
      Be sure to subscribe to stay updated on the latest with Flutter:
      goo.gle/FlutterYT 🙌

  • @GoldGiver
    @GoldGiver 2 ปีที่แล้ว

    Thanks for the kind explanation. 👍🏼

    • @flutterdev
      @flutterdev  2 ปีที่แล้ว

      It's our pleasure! Thank you for watching! 👍🏽

  • @heshansandeepa9471
    @heshansandeepa9471 ปีที่แล้ว

    Very nice

  • @vasanthkorada4802
    @vasanthkorada4802 2 ปีที่แล้ว

    Awesome

  • @iamawesomeheheh
    @iamawesomeheheh ปีที่แล้ว

    This is a very good topic and I appreciate the Flutter team for putting this out. While the explanations on the illustrations vs actual code by Michael Thomsen is digestable, the other one is not.
    1. Illustrations by Michael Goderbauer is also good but when it comes to the actual code, it would be better for him to utilize the cursor so it shows the specific area of the code he is explaining
    2. For him to show the before code and after codes that would be a good visualization of the changes
    3. For him to make it more interactive like show his face in a thumbnail mode on the side while showing the code IDE and NOT just use the presentation decks
    I kept on pausing and running back and forth to understand the entirety of the code snippets. I hope they'll take this feedback constructively and improve it. Thanks again!

  • @scottgreen3703
    @scottgreen3703 2 ปีที่แล้ว

    I hope you show us ho to change values in bottom navigation bar fromdiffren pages

  • @ozanmuyes
    @ozanmuyes 2 ปีที่แล้ว +1

    The video is indeed informative (except for the mentioned things in other comments, like it doesn't work on web) but the contrast is too much for the colors and for the sound. Those make the video hard to follow.

  • @michasengotta2295
    @michasengotta2295 2 ปีที่แล้ว +2

    Great idea to have a loud ringing sound in a TH-cam video that purposefully comes out of nowhere.

  • @lesptitsoiseaux
    @lesptitsoiseaux 2 ปีที่แล้ว

    In the 90s we had to deal with this too. Have fun kids!

  • @Joshua-dc4un
    @Joshua-dc4un 2 ปีที่แล้ว +1

    Does it work on the web? Is it achieved using web workers

  • @user-hw6xm5fk2k
    @user-hw6xm5fk2k ปีที่แล้ว

    cool

  • @kaustavchatterjee366
    @kaustavchatterjee366 2 ปีที่แล้ว

    I thought I heard something about isolateGroups that will share memory, is that a thing?

  • @falkmuller232
    @falkmuller232 2 ปีที่แล้ว

    Nice Video! However, AFAIK Isolates are not supported on the web, are they? I think that would make a fine addition.

    • @miksen
      @miksen 2 ปีที่แล้ว +1

      Yes, unfortunately Flutter web doesn't currently support isolates. We'll get the documentation updated to make that a bit clearer.

  • @chondrosatriowibowo8391
    @chondrosatriowibowo8391 2 ปีที่แล้ว

    Hello all, can i know how to download file on background processing?

  • @lucasfrancelino5141
    @lucasfrancelino5141 2 ปีที่แล้ว +2

    What about web?

  • @rixclock
    @rixclock 9 หลายเดือนก่อน

    Is compute or Isolate available now in Flutter Web?

  • @aytunch
    @aytunch 2 ปีที่แล้ว +1

    Thanks for this. Is the "_entryPoint" at 11:51 supposed to be same with "isolateEntryPoint" at 13:05? Is it a typo?

  • @alanchae24
    @alanchae24 2 ปีที่แล้ว +2

    is it possible using firestore (fetching, writing and so on) also with compute or another isolate ??
    we’re building service using flutter & firebase that our backend functions heavily depend on firebase.
    so we wanna know it is possible or not. i searched and tried pretty much, but i havenot figured out how to do it!

    • @atoli1425
      @atoli1425 2 ปีที่แล้ว +1

      From my testing that is not possible. Maybe you can offload the processing of the data to an isolate but not the fetch

    • @erde_gaming_
      @erde_gaming_ 2 ปีที่แล้ว

      You can delegate the parsing to isolate, but that's all. (still better than nothing)

    • @alanchae24
      @alanchae24 2 ปีที่แล้ว

      thanks for reply, guys!!

    • @huytruonghung4374
      @huytruonghung4374 2 ปีที่แล้ว

      I think it's better to use isolate when you are working on a heavy CPU computational task such as image processing, parse large JSON, AI related task,... Networking doesn't require much CPU so normal async/await is suffice.

  • @fan23fan
    @fan23fan 2 ปีที่แล้ว

    I guess that vm in vm thread stands for virtual machine. Or is it something else? Would be better if you clarified this part. What is it? What does it do?

    • @michaelthomsen6857
      @michaelthomsen6857 2 ปีที่แล้ว

      That is correct. The work it does depends a bit on what format the Dart code is compiled to. When you AOT compile (flutter release builds and `dart compile exe`), the code is ready to execute but still needs a runtime environment to handle things like Dart memory management (garbage collection) and runtime type-checking for non-static types. When running in JIT mode (flutter debug/development builds), the VM further handles the interpretation of the code and JIT-compilation to native code.

  • @aytunch
    @aytunch 2 ปีที่แล้ว

    on the line "final engine = GameEngine();" We are instantiating the game engine which we are already implementing (class ConcurrentGameEngine implements GameEngine). Isn't it already initialized and can't we access it by using 'this" or something? Please can you clarify this?

    • @teajay6545
      @teajay6545 2 ปีที่แล้ว +1

      Implementing != initialization && instantiating != initializing. When you implement a class, you inherit its methods, which you then override and define its actions.(eg makeMove, reportMove) Instantiating means you get a new instance of the class which lets you access its methods/members = GameEngine(), now you can initialize final engine = GameEngine() instance, and access like so: engine.start() or you can use the instance GameEngine().start() this will make you create a new instance each time you want to access a new method, which may not be what you want. Hope this helps.

    • @aytunch
      @aytunch 2 ปีที่แล้ว

      @@teajay6545 Yeah thanks. I was actually bothered by GameEngine() being initaited more than once. Maybe it should have been a Singleton?

  • @benjaminli21
    @benjaminli21 2 ปีที่แล้ว

    Hmm...
    I have a super performance damaging issue. When you scroll on a list with a lot of images that contains a lot of color, there's a certain highly noticable lagging feel from scrolling.
    And from DartDevTool, I can tell it's because of the re-rendering or rendering of the images that cause trouble here.
    But is there a way to move the rendering of images using isolate?

    • @ffactory945
      @ffactory945 2 ปีที่แล้ว

      Have you considered using a lazy list?

    • @benjaminli21
      @benjaminli21 2 ปีที่แล้ว

      @@ffactory945 hmm... Well, I tried. But since there's no improvement, I don't think it's because of rendering all at once that cause the scrolling lagging.

    • @ffactory945
      @ffactory945 2 ปีที่แล้ว

      @@benjaminli21 Are your images very high high resolution?

    • @benjaminli21
      @benjaminli21 2 ปีที่แล้ว

      @@ffactory945 Yes. I supposed they are. Very beautiful images 😄

    • @ffactory945
      @ffactory945 2 ปีที่แล้ว +3

      @@benjaminli21 high resolution on a mobile screen doesn't make a difference. Try to display a downsized version of the images instead. The image width should match the device width if possible, anything more is only noticeable when zooming.

  • @tobias6361
    @tobias6361 2 ปีที่แล้ว

    How do I check if “code runs longer than the frame budget“?

    • @alibakhtiyari9216
      @alibakhtiyari9216 2 ปีที่แล้ว +1

      you should run your app on profile mode

  • @UrgentSnooker
    @UrgentSnooker 2 ปีที่แล้ว +2

    Hey that's a very interesting video but I have a question: why in your captions do you specify the pronouns for your guests? Don't you expect that it is obvious that people with masculine appearance and the name of Michael are obviously males using he/him pronouns? I'll appreciate your answer since I was recently offered to make similar video instructions in a software development company I'm working at and so I would like to know If it's a new industry practice that I should follow as well if we're targeting English-speaking audiences. Again, great video of yours, I'm following them closely as I advance in my Flutter developer career.

    • @andrewbrogdon558
      @andrewbrogdon558 2 ปีที่แล้ว +3

      Great question! It's definitely something that's becoming more common, though I wouldn't say every English-language tech video includes them. My understanding of the reasoning is that different people use different pronouns (he, she, they, and so on), and it isn't always obvious from the way a person looks which one fits them best. Personally, I'm a two-hundred pound dude with a beard and vague smell of sawdust, so most people correctly guess "he/him" when speaking to me. By being explicit about my pronouns, though, I think it makes it easier for everyone else to be clear about theirs, and since it only takes a few seconds to include them, why not? :)

  • @michasengotta2295
    @michasengotta2295 2 ปีที่แล้ว +6

    All of this is useless for web. Could've mentioned that.

  • @pawanjoshee
    @pawanjoshee 2 ปีที่แล้ว

    Please hire a professional TH-cam thumbnail designer first. It's boring...