Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hot reloading or JS/HTML backend? #107

Closed
MarcWeber opened this issue Jun 12, 2022 · 7 comments
Closed

Hot reloading or JS/HTML backend? #107

MarcWeber opened this issue Jun 12, 2022 · 7 comments

Comments

@MarcWeber
Copy link

samples/counter -> duplicate the text widget and i get:

Compiling to Dart... @18:46
  sample.counter
  I like when a plan comes together! πŸ‘¨β€πŸ¦³

Performing hot reload...                                        

══║ EXCEPTION CAUGHT BY SCHEDULER LIBRARY
β•žβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
The following _CompileTimeError was thrown during a scheduler callback:
Unimplemented handling of missing static target

When the exception was thrown, this was the stack:
#0      Element.debugFillProperties (package:flutter/src/widgets/framework.dart:4396:14)
#1      StatefulElement.debugFillProperties (package:flutter/src/widgets/framework.dart:5124:11)
#2      DiagnosticableNode.builder.<anonymous closure>
(package:flutter/src/foundation/diagnostics.dart:2875:17)
#3      DiagnosticableNode.builder (package:flutter/src/foundation/diagnostics.dart:2878:8)
#4      DiagnosticableNode.getProperties
(package:flutter/src/foundation/diagnostics.dart:2892:105)
#5      DiagnosticsProperty.toJsonMap (package:flutter/src/foundation/diagnostics.dart:2613:57)
JsonList.<anonymous closure>
(package:flutter/src/foundation/diagnostics.dart:1662:19)
#7      MappedListIterable.elementAt (dart:_internal/iterable.dart:413:31)
#8      ListIterator.moveNext (dart:_internal/iterable.dart:342:26)
#9      new _GrowableList._ofEfficientLengthIterable (dart:core-patch/growable_array.dart:189:27)
#10     new _GrowableList.of (dart:core-patch/growable_array.dart:150:28)
#11     new List.of (dart:core-patch/array_patch.dart:51:28)
#12     ListIterable.toList (dart:_internal/iterable.dart:213:44)
#13     DiagnosticsNode.toJsonList (package:flutter/src/foundation/diagnostics.dart:1663:8)
#14     DiagnosticsNode.toJsonMap.<anonymous closure>
(package:flutter/src/foundation/diagnostics.dart:1625:25)
#15     DiagnosticsNode.toJsonMap (package:flutter/src/foundation/diagnostics.dart:1638:6)
#16     WidgetInspectorService._nodeToJson
(package:flutter/src/widgets/widget_inspector.dart:1517:18)
#17     WidgetInspectorService._reportStructuredError
/widget_inspector.dart:925:44)
#18     FlutterError.reportError (package:flutter/src/foundation/assertions.dart:1177:14)
#19     _debugReportException (package:flutter/src/widgets/framework.dart:6399:16)
#20     BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2657:11)
#21     WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:866:21)
#22     RendererBinding._handlePersistentFrameCallback
(package:flutter/src/rendering/binding.dart:367:5)
#23     SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1146:15)
#24     SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1083:9)
#25     SchedulerBinding.scheduleWarmUpFrame.<anonymous closure>
(package:flutter/src/scheduler/binding.dart:864:7)
══════════════════════════════════════════════════
══
Reloaded 2 of 592 libraries in 871ms.
Application finished.
EOF

Restarting the pocess works but is very time consuming.

Even flutter to web causes a 5.9MB JS libarry to be loaded.
Are there are any plans to reimplement some flutter widgets so that they can be translated to simple and fast HTML/JS nut using Flutter?

@cgrand
Copy link
Contributor

cgrand commented Jun 12, 2022

The error you get is a hot reload error (most reloads fail at the moment because our class names are not stable enough). The workaround is to just press [return] in the terminal. This will trigger a hot restart.

As of JS. We have no plan to bypass flutter. However did you try a production build. The JS should be smaller.

@MarcWeber
Copy link
Author

Hitting enter takes quite long cause its triggering many phases. Thanks for the tip about production build will try. Maybe some special dummy function suggesting a class name can be introduce for what programmers considers to be a component till a better solution is found. Cause if it was possible to have 1 sec hot reload cycles it would be awesome.

@cgrand
Copy link
Contributor

cgrand commented Jun 13, 2022

How long are your reload and restart cycles?
Using a deftype for important widgets create a stable name.

@cgrand
Copy link
Contributor

cgrand commented Jun 13, 2022

Related to #42

@MarcWeber
Copy link
Author

MarcWeber commented Jun 13, 2022

marcweber@Marcs-Air counter % (  clj -M -m cljd.build flutter ; ) | while read f; do echo -n $(date) ""; echo $f; done      
Mon Jun 13 11:48:45 CEST 2022 === Warming up `.clojuredart/libs-info.edn` === (helps us emit better code)
Mon Jun 13 11:48:45 CEST 2022 
Mon Jun 13 11:48:45 CEST 2022 === Adding dev dependencies ===
Mon Jun 13 11:48:47 CEST 2022 Resolving dependencies...
Mon Jun 13 11:48:47 CEST 2022 _fe_analyzer_shared 38.0.0 (40.0.0 available)
Mon Jun 13 11:48:47 CEST 2022 analyzer 3.4.1 (4.1.0 available)
Mon Jun 13 11:48:47 CEST 2022 meta 1.7.0 (1.8.0 available)
Mon Jun 13 11:48:47 CEST 2022 path 1.8.1 (1.8.2 available)
Mon Jun 13 11:48:47 CEST 2022 source_span 1.8.2 (1.9.0 available)
Mon Jun 13 11:48:47 CEST 2022 string_scanner 1.1.0 (1.1.1 available)
Mon Jun 13 11:48:47 CEST 2022 Got dependencies!
Mon Jun 13 11:48:47 CEST 2022 
Mon Jun 13 11:48:47 CEST 2022 === Fetching dependencies ===
Mon Jun 13 11:48:47 CEST 2022 Resolving dependencies...
Mon Jun 13 11:48:48 CEST 2022 _fe_analyzer_shared 38.0.0 (40.0.0 available)
Mon Jun 13 11:48:48 CEST 2022 analyzer 3.4.1 (4.1.0 available)
Mon Jun 13 11:48:48 CEST 2022 meta 1.7.0 (1.8.0 available)
Mon Jun 13 11:48:48 CEST 2022 path 1.8.1 (1.8.2 available)
Mon Jun 13 11:48:48 CEST 2022 source_span 1.8.2 (1.9.0 available)
Mon Jun 13 11:48:48 CEST 2022 string_scanner 1.1.0 (1.1.1 available)
Mon Jun 13 11:48:48 CEST 2022 Got dependencies!
Mon Jun 13 11:48:49 CEST 2022 
Mon Jun 13 11:48:49 CEST 2022 === Dumping type information (it may take a while) ===
WARNING: could not analyze 'counter' package 
Mon Jun 13 11:50:13 CEST 2022 
Mon Jun 13 11:50:13 CEST 2022 === Compiling cljd.core to Dart ===
Mon Jun 13 11:50:21 CEST 2022 
Mon Jun 13 11:50:21 CEST 2022 === Compiling to Dart... === @11:50
Mon Jun 13 11:50:21 CEST 2022 sample.counter
Mon Jun 13 11:50:21 CEST 2022 Oh noes! 😡
Mon Jun 13 11:50:21 CEST 2022 Error while host-compiling (deftype* InheritedBindings [state pctx snapshot child] {:extends (widgets/InheritedModel. :child child)} (isSupportedAspect [this name] (contains? snapshot name)) (updateShouldNotify [this prev-this] (not= snapshot (.-snapshot prev-this))) (updateShouldNotifyDependent [this prev-this aspects] (let [prev-snapshot (.-snapshot prev-this)] (boolean (some (fn [[name q]] (-updated? (snapshot name) (prev-snapshot name) q)) aspects)))))
Mon Jun 13 11:50:21 CEST 2022 (deftype* InheritedBindings [state pctx snapshot child] {:extends (widgets/InheritedModel. :child child)} (isSupportedAspect [this name] (contains? snapshot name)) (updateShouldNotify [this prev-this] (not= snapshot (.-snapshot prev-this))) (updateShouldNotifyDependent [this prev-this aspects] (let [prev-snapshot (.-snapshot prev-this)] (boolean (some (fn [[name q]] (-updated? (snapshot name) (prev-snapshot name) q)) aspects)))))
Mon Jun 13 11:50:21 CEST 2022 (deftype InheritedBindings [state pctx snapshot child] :extends (widgets/InheritedModel. :child child) (isSupportedAspect [this name] (contains? snapshot name)) (updateShouldNotify [this prev-this] (not= snapshot (.-snapshot prev-this))) (updateShouldNotifyDependent [this prev-this aspects] (let [prev-snapshot (.-snapshot prev-this)] (boolean (some (fn [[name q]] (-updated? (snapshot name) (prev-snapshot name) q)) aspects)))))
Mon Jun 13 11:50:21 CEST 2022 === (ns sample.counter "The perennial counter demo." (:require ["package:flutter/material.dart" :as m] [cljd.flutter.alpha :as f])) ===
Mon Jun 13 11:50:21 CEST 2022 Can't resolve widgets/InheritedModel (no source location)
Mon Jun 13 11:50:21 CEST 2022 
Mon Jun 13 11:50:21 CEST 2022 === Lauching flutter run ===
Mon Jun 13 11:50:24 CEST 2022 Launching lib/main.dart on VKY L09 in debug mode...
Mon Jun 13 11:50:50 CEST 2022 Running Gradle task 'assembleDebug'...                             25,4s
Mon Jun 13 11:50:53 CEST 2022 βœ“  Built build/app/outputs/flutter-apk/app-debug.apk.
Mon Jun 13 11:51:01 CEST 2022 Installing build/app/outputs/flutter-apk/app.apk...                 8,4s




// duplicating Text .. triggering rebuild
Mon Jun 13 11:56:53 CEST 2022 
Mon Jun 13 11:56:53 CEST 2022 === Compiling to Dart... === @11:56
Mon Jun 13 11:56:53 CEST 2022 sample.counter
Mon Jun 13 11:56:54 CEST 2022 Something horrible happened! 😱
Mon Jun 13 11:56:54 CEST 2022 Error while host-compiling (deftype* InheritedBindings [state pctx snapshot child] {:extends (widgets/InheritedModel. :child child)} (isSupportedAspect [this name] (contains? snapshot name)) (updateShouldNotify [this prev-this] (not= snapshot (.-snapshot prev-this))) (updateShouldNotifyDependent [this prev-this aspects] (let [prev-snapshot (.-snapshot prev-this)] (boolean (some (fn [[name q]] (-updated? (snapshot name) (prev-snapshot name) q)) aspects)))))
Mon Jun 13 11:56:54 CEST 2022 (deftype* InheritedBindings [state pctx snapshot child] {:extends (widgets/InheritedModel. :child child)} (isSupportedAspect [this name] (contains? snapshot name)) (updateShouldNotify [this prev-this] (not= snapshot (.-snapshot prev-this))) (updateShouldNotifyDependent [this prev-this aspects] (let [prev-snapshot (.-snapshot prev-this)] (boolean (some (fn [[name q]] (-updated? (snapshot name) (prev-snapshot name) q)) aspects)))))
Mon Jun 13 11:56:54 CEST 2022 (deftype InheritedBindings [state pctx snapshot child] :extends (widgets/InheritedModel. :child child) (isSupportedAspect [this name] (contains? snapshot name)) (updateShouldNotify [this prev-this] (not= snapshot (.-snapshot prev-this))) (updateShouldNotifyDependent [this prev-this aspects] (let [prev-snapshot (.-snapshot prev-this)] (boolean (some (fn [[name q]] (-updated? (snapshot name) (prev-snapshot name) q)) aspects)))))
Mon Jun 13 11:56:54 CEST 2022 === (ns sample.counter "The perennial counter demo." (:require ["package:flutter/material.dart" :as m] [cljd.flutter.alpha :as f])) ===
Mon Jun 13 11:56:54 CEST 2022 Can't resolve widgets/InheritedModel (no source location)




ENTER
Exception in thread "Thread-4" java.io.IOException: Stream closed
	at java.base/java.lang.ProcessBuilder$NullOutputStream.write(ProcessBuilder.java:445)
	at java.base/java.io.OutputStream.write(OutputStream.java:162)
	at java.base/java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:81)
	at java.base/java.io.BufferedOutputStream.flush(BufferedOutputStream.java:142)
	at java.base/sun.nio.cs.StreamEncoder.implFlush(StreamEncoder.java:320)
	at java.base/sun.nio.cs.StreamEncoder.flush(StreamEncoder.java:160)
	at java.base/java.io.OutputStreamWriter.flush(OutputStreamWriter.java:250)
	at cljd.build$compile_cli$fn__6809.invoke(build.clj:231)
	at clojure.lang.AFn.run(AFn.java:22)
	at java.base/java.lang.Thread.run(Thread.java:833)

Relead doesn't happen at all right now. Will try a setup eg docker I can reproduce.

https://github.com/Tensegritics/ClojureDart/blob/main/doc/flutter-quick-start.md
Would be a great way to introduce deftype in that sample. I need to look it up.
I am not that fluent in Clojure (yet).

and yes release build only 3.2MB (total resources) targeting web html. Which is much but bearable. Still much for just a simple counter.

@cgrand
Copy link
Contributor

cgrand commented Jun 13, 2022

Several things going on here:

  • Can't resolve widgets/InheritedModel it looks like Flutter is not a dep, how did you init the project/what's the pub spec.yaml like?

  • Stream closed it means the flutter subprocess itself has failed. It's not a graceful failure mode. Opened Gracefully handling flutter exitsΒ #108

@MarcWeber
Copy link
Author

MarcWeber commented Jun 14, 2022

See #110 #42
Closing this because there are other issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants