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

Rework components cache #53

Merged
merged 2 commits into from
Feb 14, 2024

Conversation

kLabz
Copy link
Contributor

@kLabz kLabz commented Jan 11, 2024

So far I have not been able to isolate the issue that Dune has on Game.hx completion, but only reproduced via a non-server example (see below). I'd need to check in more details what buildDocument does in order to make a simple repro of the compilation server issue.

The problem I'm seeing on the original issue is:

Initial compilation:

  • Note: no registration for ui.menu.$, only ui.menu.$UI
  • ui.menu.Screen enters its buildObject, and add itself (temporarily) to RESOLVED_COMPONENTS
  • Screen's buildDocument triggers (indirectly) build of ui.LoadingScreen.MenuLoadingScreen, which has ui.menu.Screen as parent class.
  • Parent class is resolved through RESOLVED_COMPONENTS
  • Screen resumes building, removes its temp entry from RESOLVED_COMPONENTS

Recompilation with Screen still in cache and ui.LoadingScreen.MenuLoadingScreen being rebuilt:

  • ui.LoadingScreen.MenuLoadingScreen enters its buildObject, looks for its parent class
  • Screen's temp entry is no longer in RESOLVED_COMPONENTS and also cannot be resolved
  • Missing super component registration screen error

Using COMPONENTS directly, by making sure we're not using discarded components, we can skip the RESOLVED_COMPONENTS business entirely.

Would still be interesting to double check on different domkit codebases.

haxelib git domkit https://github.com/kLabz/domkit fix/missing-comp-registration

Example without server

Main.hx

trace(components2.Comp2);

components1/Comp1.hx

package components1;

class Comp1 extends h2d.Flow implements h2d.domkit.Object {
	static var SRC =
		<comp1>
			<text text={"Hello World"}/>
		</comp1>;

	public function new(?parent) {
		super(parent);
		initComponent();
	}

}

components2/Comp2.hx

package components2;

class Comp2 extends components1.Comp1 {
	static var SRC =
		<comp2>
			<text text={"Hello World"}/>
		</comp2>;


	public function new(?parent) {
		super(parent);
		initComponent();
	}

}

Before: Missing super component registration comp1
After: Ok

@kLabz
Copy link
Contributor Author

kLabz commented Feb 14, 2024

Should close #30

@ncannasse ncannasse merged commit 7757c0f into HeapsIO:master Feb 14, 2024
@ncannasse
Copy link
Member

Seems good as it gets rid of the RESOLVED_COMPONENTS which was a bit of a hack. Let's merge for now so it can be battle-tested.

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

Successfully merging this pull request may close these issues.

2 participants