-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Read from FyneApp.toml when developing with go tools #4715
Conversation
This means we can just 'go run .' and get icons etc. Fixes fyne-io#4688
I’m not entirely sure about this. Now every app will try to load FyneApp.toml on startup from the local directory. That doesn’t go well with the fact that this is a very specific developer problem mostly on Windows. 99% of all non development installs will not use this. I think we either need a better solution or make sure that this functionality is turned off when building a release binary. I prefer the former though as I can’t build Flatpak apps with -tags release. |
Maybe the better option just simply is to allow the developer to turn off the windowsgui linker flag? |
I don't understand this comment? The change enables usage of "go run" lifecycle and using the "run" button inside IDEs. |
Unless I coded it wrong I don't think this is the case. It will only look for local metadata if none was packaged. Which means for any packaged app, or released bundle, this code will never execute.
Erm... this is something that is useful to anybody wanting to use standard Go tools for their development cycle instead of packaging then running if their app uses metadata... |
I’m sorry if my comments didn’t summarise clearly what I meant. The use case in the issue describes Windows and not wanting If a user wants to have metadata during development, then switching to “fyne build” from “go build” is not such a bug change. We did design the build command to basically a drop in replacement. If that’s not the case for some use cases we might want to look into that. |
Yes, I expressed myself incorrectly there. What I mean is that there are cases where we have production builds that just can't use the |
I think this is a different problem and not one I had fully comprehended - they will not support metadata at all in the current state, or after the PR lands (as the file will be missing at runtime) |
This just seems like complexity to me. The Go tools create simple binaries and the fyne tool is for bundling graphical apps. This seems like a strong divide that we should stick to. |
I don't quite agree with that given that we added the "fyne build" command for the very reason of building regular binaries in the same sense as "go build" without any bundling but with customisations to make the binaries more adapted to guis. |
Maybe I used the wrong words, but the sentiments are basically the same - go tools for CLI and fyne tools for GUI apps. If you add an option to create a GUI app without it being a GUI app then we will have to explain complex technical issues specific to OS that (if we have done our job right) people should never have to worry about. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added some comments inline. Also, should we try to not compile in the runtime metadata lookup if we know that the metadata was added? I.e. should we avoid compiling it in if we have release
as build mode?
One thought (not necessarily something you need to fix): This can theoretically lead to strange behaviour if a binary was built without metadata in the past and runs in a directory that has a FyneApp.toml
file. Might not be a meaningful problem but I feel it is worth noting.
app/meta_development.go
Outdated
@@ -0,0 +1,40 @@ | |||
//go:build !no_metadata |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of more complexity (more files) in the app/
folder, can you not use the new internal/build
package and add a build.NoMetadata
constant?
You can then just to an if build.NoMetadata
before calling the function. Mates things a bit clearer, I think :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of more complexity (more files) in the
app/
folder, can you not use the newinternal/build
package and add abuild.NoMetadata
constant?You can then just to an
if build.NoMetadata
before calling the function. Mates things a bit clearer, I think :)
Won't this still be another new file? by placing it in the build folder it is disconnected from the metadata handling code.
I don't have a strong opinion one way or another - but isn't it a case of introducing a new constant and yet we have the same number of new files?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right that it won't result in less files but it would avoid adding more files to the already crowded app/ folder. The files in the other package are easier to grasp what they do. It is also consistent with how we check other build tags using that internal/build package.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK done.
Just to be clear this change means:
- 1 extra file
- A package public constant checked in 1 place
- the toml package cannot be ignored during compile
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The first two are correct but will have less meaning if we use them in more places in the future. You can move the single function into another file also if you want to as well.
The third one, about toml not being ignored should not be correct. As the NoMetadata and Type values are constant, the compiler can dead-code eliminate the branches where they are used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The third one, about toml not being ignored should not be correct. As the NoMetadata and Type values are constant, the compiler can dead-code eliminate the branches where they are used.
I guess this is getting a little into semantics but I think we are both right. The package cannot be ignored during compile - however it may be possible that the compiler later optimises it out as you say.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup. It will likely be downloaded but it should not be part of the binary :)
app/meta_development.go
Outdated
) | ||
|
||
func checkLocalMetadata() { | ||
file, _ := filepath.Abs("FyneApp.toml") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might want to check the error here, I think
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This went away
Sorry, I realised something. It is worth noting that this does bring in the toml dependency into every binary. You ought to check binary sizes and add that checkbox back to the PR template. |
Thinking a bit more about this, I'm afraid that think this kind of brings more downsides for applications than upsides in its current implementation. Bundling the toml parsing into every app, apps without metadata will try to load metadata from PWD (unless it uses that tag to avoid it) and an app without metadata potentially loading the wrong metadata if launched from another directory seems bad in my opinion. I'd instead propose adding a "runtime_metadata" tag to explicitly enable this for those that want it. If we introduce a "fyne run" command, it can use that tag automatically. |
I take your point - but adding a flag to do this essentially removes the point of it. If you do add that flag then the same problem you report with taking the wrong data still occurs for any apps built with that turned on. |
We introduced the "fyne build" command basically to support metadata because "go build" couldn't. I agree that we for the most part shouldn't force people to use our cmd commands but I do see a tag for runtime metadata lookup as the best option given the tradeoffs mentioned above.
Yes but there is a very important distinction there. The potentially problematic behaviour is no longer by default and won't happen without you knowing. |
I agree with @Jacalz - expecting |
…xecuting in, if we can.
This has been addressed with the latest commit - loading only from the source directory (or PWD if it's a temporary go build i.e. "go run"). |
As a general comment I don't like the idea that "just working" is something we should /not/ strive for...
I would hope that everything we do is to make either the user or the developers life easier, and to take the path of least surprise. |
Alright, last comment on trying to bridge the philosophical gap here between @andydotxyz and @Jacalz + myself. What if we use |
I already suggested disabling it for the release tag further up in the thread (during my code review). However, we can't rely on that tag being set for Flatpak and Linux builds in general. Even if we add a |
I kind of think it is easier to put the "you need to look up this compile tag to improve things" on the developer of the Fyne app rather than the package maintainer. |
I'm sorry but I don't agree with this. The go tools and source build are used a lot more by developers and consumers of GitHub code than packagers. With the current exception of flatpak app packaging is done with "fyne" tool. |
Not Flatpak only. I'd say that it is more like all of the Linux packages in repositories. I.e. Rymdport I'm AUR, Solus, Nix and so on. That's the majority of Linux packages there. Might even apply to BSD* if their build systems behave in a similar way. |
I think we are losing sight of the purpose of the tools we have created. The |
Good idea - done.
There should be no code required in applications to make sure that metadata is all bundled correctly. With these changes it will work in all cases except when you are manually turning metadata off. If that is a desire of your app then the same build flags can be used to insert your own version of metadata instead. No overlap and no ambiguity. |
This is returning to the old problem of "why is my icon not working" bugs where the code was missing, so we added automatic metadata handling so that it just worked. Reverting to the old method is going to introduce new unexpected corner cases and require that people a) read the documentation and b) insert more code into their app to get it working for the default tooling. Both are things I would like to avoid, especially as we saw this exact thing play out with app icons before it. |
Would you mind addressing the review comments that I have inline from the last review? I think they are still valid. |
It was just a thought experiment around using more |
All I was trying to say is that it isn't an exception given that it basically applies to all Linux package systems because we can't rely on the |
I think that "packager does not have the latest packaging tool installed" can be considered a corner case. It's surely in the same camp as "packager's Go version is not new enough for this app"? |
Done. As far as I can see it was only a missed defer that still applied. |
I think this comment still is valid: |
I wouldn't directly put it in the same camp. One makes it impossible to compile and the other would just not support metadata or some other missing functionality. EDIT: Yes, in the case where it might break stuff. It is also worth noting that on an LTS version of Linux, the fyne command will likely never be as new as the Fyne version of the app (if we assume they stick to a minor release for the whole life cycle). A rolling release would potentially be less of an issue but there it might instead be too new if you haven't updated the app in a while. |
Indeed that possibly poses a problem - as it always has done. But of course we have Fyne-cross if people don't have the right versions of tooling for the packaging process. |
Apologies, for some reason GitHub had completely hidden that. |
OK, I think this is now a solution that a) "just works" for most go based development flow |
I would just check for binary size increases with a release build, and if it doesn't go up, or goes up minimally (a few %?), I'm fine with this now |
Looks like a release (or no_metadata) build is 18KB increase, that's 0.06%. |
Sounds very sensible. Bigger difference for a regular development build? |
yeah it was around 2/3 of 1% |
I think the changes requested are all sorted @Jacalz |
I think so too after a quick glance. Will review once I'm back at my computer on Monday |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one minor comment that has some strange wording. Approved in all other ways :)
app/meta_development.go
Outdated
return work | ||
} | ||
|
||
// we were called with after "go build" completed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there is a mistake in this comment. The wording does not quite make sense?
Fixes the go run and go build finding metadata during development.
Fixes #4688 and fyne-io/tools#12
Checklist: