We're currently dealing with crashes across all Qt applications using QML on NixOS [1], since Qt utilizes the binary's mtime to invalidate the cache of embedded QML resources.<p>Since all builds have an mtime of 0 as timestamps are the biggest source of reproducibility issues [2], QML loads outdated cache objects which will then load invalid bytecode at runtime and therefore causing a crash.<p>Our initial plan was to utilize a hash of the binary [3] which should be IMHO the most straightforward, unlikely to break and future-proof way to solve the problem. The currently suggested implementation's performance could most likely be improved by generating the hash once on startup instead of every time when a QML resource is loaded, but I believe since it's already cached in memory, hashing is not that expensive, binary sizes are usually relatively small and resource loading (of embedded ones) doesn't happen that often, it should be already reasonably fast (real performance test haven't been done yet).<p>The big challenge will be upstreaming it, once we've proven it to properly work. The current approach has been apparently rejected [4] and was declared to be a downstream issue, which I personally don't agree with, since sooner or later reproducible builds will become the norm and therefore will affect everyone.
Current ideas to work around it require individual solutions per distribution/ISV, as this would mean they'd have to come up with domain specific criteria for cache invalidation (as the store path/derivation hash on NixOS) and to maintain a downstream patch for this solution and furthermore wouldn't work for local build processes (e.g. from within an IDE).<p>Lesson of the day: never use mtimes, they'll bite you in the ass sooner or later!<p>[1] <a href="https://github.com/NixOS/nixpkgs/issues/177720" rel="nofollow">https://github.com/NixOS/nixpkgs/issues/177720</a><p>[2] <a href="https://reproducible-builds.org/docs/timestamps/" rel="nofollow">https://reproducible-builds.org/docs/timestamps/</a><p>[3] <a href="https://github.com/qt/qtdeclarative/commit/5106afcd76e377a6bbcdda578b9efd5167447ec0" rel="nofollow">https://github.com/qt/qtdeclarative/commit/5106afcd76e377a6b...</a><p>[4] <a href="https://github.com/NixOS/nixpkgs/issues/177720#issuecomment-1244763504" rel="nofollow">https://github.com/NixOS/nixpkgs/issues/177720#issuecomment-...</a>