-
-
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
Feature/metadataapi #2813
Feature/metadataapi #2813
Conversation
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 a small typo, apart that LGTM
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 looks very promising to me. I know that this is a draft but I just had two questions inline.
Fix typo Co-authored-by: Luca Corbo <lu.corbo@gmail.com>
I cannot figure out these test failures. They are passing correctly on my fork but failing here (and pass on my desktop too). |
This is very weird, but I have the impression that it is actually merging with develop and running the tests from develop. If you do a manual merge locally, you should be able to see them too. |
Hmm, I thought I had done so, but maybe a day or two back was not enough ;) |
Amazing, this was bang on thanks. Fixed :) |
I'll try to have a look at this later today or tomorrow. |
This might be a silly idea, but could address @Jacalz concern. What do you think of having a "fyne metadata" command line that read the metadata and generate a go file instead. This could be used then by go generate. This would make go build actually work and provide metadata too. |
Can you elaborate a bit more in how you intend it to be used and how it is different from |
Yes we could do this. However metadata can change (version numbers etc) and forgetting to run this would mean the version info is out of date. Also exposing the |
By reading its information from the FyneApp.toml and generating the proper metadata structure. Very different job compared to fyne bundle, I think. |
I agree there is a synchronization problem. fyne package could maybe run go generate to make sure it is in sync, but for someone using go build, they would have to do it manually and thus the risk of not being in sync. Neither are ideal solution and both have drawback. I am personally fine with both as long as there drawback are documented. |
Ah cunning, combine the best of both. Inject latest into generated source code so go build still works. That sounds genius and may be possible. It might require another API because the app would have to inject the data instead of using the compiler. Will have to think about this more to see if it can be done more cleanly. |
I looked into this further and unfortunately I don't think it's practical. If the developer forgets to commit the file, and they use the |
I’m genuinely sorry but I would still vote for keeping the icon part out for now and implementing it at a later date. That way we can get more time to think about a better solution that doesn’t have the current drawbacks. This API will be great even without the icon. I think you've done a great job with it. It kind of falls in line with the extra build metadata that was added for Go 1.18 (that might even be useful for this in the future). |
Info for the 3 different builds, "basic" is just
Although the source code is much smaller (no bundle file, but even if there was the MD5 is half the size of the bundled byte array source) the compiled image data is around 2% smaller bundled (compared with image size) vs around 30% larger than the source image due to the MD5 storage format. I could look at different string encodings for the image data I guess. |
Just a quick reminder of the current scanario:
As you can see above it basically requires user adding code into the app and bundling the icon manually to get it everywhere.
The potential downside is that users bundling their own icon manually may have it stored twice when packaging for the benefit of controlling it's manual inclusion when not packaging and using "go build" only. I can see that this is a tradeoff, but I think the lowered inconvenience for the primary target (packaging) is worth it for the possible downside during development (avoiding fyne tools and finding the icon not inserted unless code added). |
I think you are right. There is no better way around this. I don't know if it's worth it, but I guess we could consider using https://github.com/cristalhq/base64 if it makes any difference? Another though that I had was if it makes sense to have an option to turn off the metadata? Something like a |
I tried some other encodings but they just didn't work (either invalid for a ldflags command line parameter, or much larger than comparison). Comparing this time to metadata included - but no icon metadata:
So base64 is actually less than half the increase than I though it was compared to the efficient bundling of bytes directly (which was +82k). It makes me feel a little better. |
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.
Looks great. This is a really nice improvement. It looks like this branch isn't updated with the fyne build
command but I guess that this will work it as well.
It didn't but I pushed an additional minor change over the top which added metadata to the serve command as well |
Add support for reading metadata through API.
More work to follow, including tests. Marked draft for discussion.
Fixes #1940 (indirectly)
Checklist: