Is image count limited on xamltoy?
Hi, i'm getting some unexpected behavior with uploaded images into xamltoy gist
I've reproduced the issue on the following xamltoy
It may well be a limitation of github gists. But from what i can read here i belive i'm within their specs.
https://docs.github.com/en/rest/gists/g ... truncation
If I understand correctly their limits are
I've reproduced the issue on the following xamltoy
It may well be a limitation of github gists. But from what i can read here i belive i'm within their specs.
https://docs.github.com/en/rest/gists/g ... truncation
If I understand correctly their limits are
- 1 Mb per file
- 300 max file count
Last edited by Rmunoz on 17 Jul 2024, 21:13, edited 1 time in total.
Re: Is image count limited on xamltoy?
I've run get request on given gist and the affected files are indeed being truncated by the api.
I've run this curl, maybe not providing authentication limits the spec even further ( i'll try again with a token )
I've run this curl, maybe not providing authentication limits the spec even further ( i'll try again with a token )
Code: Select all
curl -L -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" https://api.github.com/gists/3a386c1c65995fc38070ac98526d5fd5Re: Is image count limited on xamltoy?
Looks like the file get response has a size limit itself of about 1MB for the list of all files.
From what I understand in the Api docs this is something that is known to happen, and when it does it marks the file with the truncated flag.
For such cases they provide the raw url field to retreive the resource.
This is not urgent for me, I can workaround these issues.
I believe looking up truncated resources with raw_url would empower richer xamltoy examples :)
From what I understand in the Api docs this is something that is known to happen, and when it does it marks the file with the truncated flag.
For such cases they provide the raw url field to retreive the resource.
This is not urgent for me, I can workaround these issues.
I believe looking up truncated resources with raw_url would empower richer xamltoy examples :)
Re: Is image count limited on xamltoy?
I've drafted a pull request with what i think would fix this issue.
Take it with a grain of salt because I haven't programmed javascript in ages :)
https://github.com/Noesis/Xamltoy/pull/19
Take it with a grain of salt because I haven't programmed javascript in ages :)
https://github.com/Noesis/Xamltoy/pull/19
Re: Is image count limited on xamltoy?
I've taken the loader script from xaml toy and drafted support for loading truncated files, i've tested for it to work on online javascript editor and they are all loading.
I've commented several sections not related to the change and hardcoded the id for the example used on this thread.
Hope it helps with the support.
I've updated the pull request with the mentioned changes
I've commented several sections not related to the change and hardcoded the id for the example used on this thread.
Hope it helps with the support.
Code: Select all
let gistFetched = false;
let resources = {};
let hash = '3a386c1c65995fc38070ac98526d5fd5';
let xaml = "Loading..."
let defaultXaml = '<Grid\n xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"\n xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">\n \n</Grid>'
if (hash) {
fetch('https://api.github.com/gists/' + hash,
{
headers: { accept: 'application/vnd.github.VERSION.base64' }
})
.then(response => { return response.json() })
.then(async response => {
let mainXaml = response.files["Main.xaml"];
if(mainXaml){
let title = response.description + " (XamlToy) | NoesisGUI";
let desc = "XamlToy: " + response.description;
let url = "https://www.noesisengine.com/xamltoy/" + hash;
////document.querySelector('title').innerHTML = title;
////document.querySelector('link[rel="canonical"').setAttribute("href", url);
////document.querySelector('meta[name="description"]').setAttribute("content", desc);
////document.querySelector('meta[property="og:title"]').setAttribute("content", title);
////document.querySelector('meta[property="og:url"]').setAttribute("content", url);
////document.querySelector('meta[property="og:description"]').setAttribute("content", desc);
// Main change starts here
let pendingLoads = [];
Object.keys(response.files).forEach(fileName => {
if (fileName !== "Main.xaml") {
let file = response.files[fileName];
if(file.truncated === false){
let byteChars = (atob(file.content));
let byteNumbers = new Array(byteChars.length);
for (let i = 0; i < byteChars.length; i++) byteNumbers[i] = byteChars.charCodeAt(i);
let byteArray = new Uint8Array(byteNumbers);
resources[fileName] = byteArray;
}
else
{
pendingLoads.push(
fetch(file.raw_url).then(async imageFetch => {
let content = new Uint8Array( await imageFetch.arrayBuffer());
resources[fileName] = content;
}));
}
}
});
// Non truncated resources
console.log(resources);
await Promise.all(pendingLoads);
// All resources
console.log(resources);
// Main change ends here
////xaml = decodeURIComponent(escape(window.atob(mainXaml.content)));
////document.getElementById('xaml-link').href = 'https://gist.github.com/' + hash;
////document.getElementById('xaml-link').style = '';
////document.getElementById('xaml-title').innerHTML = response.description;
gistFetched = true;
}else{
console.warn("Gist does not contain Main.xaml.");
loadDefault();
}
})
.catch((err) => {
console.warn( err + "Could not fetch data from Gist. Please check the Gist id.");
loadDefault();
})
} else {
loadDefault();
}
function loadDefault(){
window.history.pushState({}, document.title, "/xamltoy/" + "");
xaml = defaultXaml;
gistFetched = true;
}I've updated the pull request with the mentioned changes
Re: Is image count limited on xamltoy?
I'm facing the same behaviour in a small gist, compound by a large image —but not large enough to be out of limits, like 800kb instead of 1Mb— and a single main xaml file which is like 200 lines of code.
Depending on whether or not the main xaml has more content, the image will or won't be loaded.
If the xaml is like 150 locs, it loads fine. Whenever I pass some amount around the 200 locs, it stops loading. It says the same error as aforementioned (Error loading file, using fallback texture).
I don't think is in the lines of code of course, but in the data size and the whatnot.
Depending on whether or not the main xaml has more content, the image will or won't be loaded.
If the xaml is like 150 locs, it loads fine. Whenever I pass some amount around the 200 locs, it stops loading. It says the same error as aforementioned (Error loading file, using fallback texture).
I don't think is in the lines of code of course, but in the data size and the whatnot.
Re: Is image count limited on xamltoy?
Thanks for the feedback about this and for the pull request with the solution! We will integrate the changes as soon as possible!
Who is online
Users browsing this forum: No registered users and 6 guests