Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…into moar-fix
  • Loading branch information
mohnjiles committed Aug 21, 2024
2 parents 4cdc506 + 83f6ded commit 43ea362
Show file tree
Hide file tree
Showing 257 changed files with 9,358 additions and 1,977 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/backport.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ jobs:
"commitConflicts": "true",
"prTitle": "[{{sourceBranch}} to {{targetBranch}}] backport: {{sourcePullRequest.title}} ({{sourcePullRequest.number}})"
}
- name: Backport Action
uses: sorenlouv/backport-github-action@v9.3.0
uses: sorenlouv/backport-github-action@v9.5.1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
auto_backport_label_prefix: backport-to-
Expand Down
Empty file modified .husky/pre-commit
100644 → 100755
Empty file.
8 changes: 7 additions & 1 deletion Avalonia.Gif/Avalonia.Gif.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,15 @@
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
<EnableWindowsTargeting>true</EnableWindowsTargeting>
</PropertyGroup>

<PropertyGroup>
<!-- Ignore nullable / unused warnings since this was vendored -->
<NoWarn>$(NoWarn);CS8765;CS8618;CS8625;CS0169</NoWarn>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Avalonia" Version="$(AvaloniaVersion)" />
<PackageReference Include="SkiaSharp" Version="2.88.7" />
<PackageReference Include="SkiaSharp" Version="3.0.0-preview.4.1" />
<PackageReference Include="DotNet.Bundle" Version="0.9.13" />
</ItemGroup>

Expand Down
29 changes: 24 additions & 5 deletions Avalonia.Gif/Decoding/GifDecoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using System;
using System.Buffers;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
Expand Down Expand Up @@ -190,7 +191,9 @@ private void RenderFrameAt(int idx, WriteableBitmap writeableBitmap)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private void DrawFrame(GifFrame curFrame, Memory<byte> frameIndexSpan)
{
var activeColorTable = curFrame.IsLocalColorTableUsed ? curFrame.LocalColorTable : Header.GlobarColorTable;
var activeColorTable = curFrame.IsLocalColorTableUsed
? curFrame.LocalColorTable
: Header.GlobarColorTable;

var cX = curFrame.Dimensions.X;
var cY = curFrame.Dimensions.Y;
Expand Down Expand Up @@ -232,7 +235,11 @@ void DrawRow(int row)
{
var indexColor = frameIndexSpan.Span[indexOffset + i];

if (activeColorTable == null || targetOffset >= len || indexColor > activeColorTable.Length)
if (
activeColorTable == null
|| targetOffset >= len
|| indexColor > activeColorTable.Length
)
return;

if (!(hT & indexColor == tC))
Expand Down Expand Up @@ -420,14 +427,20 @@ private void WriteBackBufToFb(IntPtr targetPointer)
unsafe
{
fixed (void* src = &_bitmapBackBuffer[0])
Buffer.MemoryCopy(src, targetPointer.ToPointer(), (uint)_backBufferBytes, (uint)_backBufferBytes);
Buffer.MemoryCopy(
src,
targetPointer.ToPointer(),
(uint)_backBufferBytes,
(uint)_backBufferBytes
);
_hasNewFrame = false;
}
}

/// <summary>
/// Processes GIF Header.
/// </summary>
[MemberNotNull(nameof(Header))]
private void ProcessHeaderData()
{
var str = _fileStream;
Expand Down Expand Up @@ -549,7 +562,9 @@ private void ProcessFrameData()

// Break the loop when the stream is not valid anymore.
if (_fileStream.Position >= _fileStream.Length & terminate == false)
throw new InvalidProgramException("Reach the end of the filestream without trailer block.");
throw new InvalidProgramException(
"Reach the end of the filestream without trailer block."
);
} while (!terminate);

ArrayPool<byte>.Shared.Return(tempBuf);
Expand Down Expand Up @@ -581,7 +596,11 @@ private void ProcessImageDescriptor(ref int curFrame, byte[] tempBuf)
currentFrame.LocalColorTableSize = (int)Math.Pow(2, (packed & 0x07) + 1);

if (currentFrame.IsLocalColorTableUsed)
currentFrame.LocalColorTable = ProcessColorTable(ref str, tempBuf, currentFrame.LocalColorTableSize);
currentFrame.LocalColorTable = ProcessColorTable(
ref str,
tempBuf,
currentFrame.LocalColorTableSize
);

currentFrame.LzwMinCodeSize = str.ReadByteS(tempBuf);
currentFrame.LzwStreamPosition = str.Position;
Expand Down
6 changes: 0 additions & 6 deletions Avalonia.Gif/Decoding/InvalidGifStreamException.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
// Licensed under the MIT License.
// Copyright (C) 2018 Jumar A. Macato, All Rights Reserved.

using System;
using System.Runtime.Serialization;

namespace Avalonia.Gif.Decoding
{
[Serializable]
Expand All @@ -16,8 +13,5 @@ public InvalidGifStreamException(string message)

public InvalidGifStreamException(string message, Exception innerException)
: base(message, innerException) { }

protected InvalidGifStreamException(SerializationInfo info, StreamingContext context)
: base(info, context) { }
}
}
6 changes: 0 additions & 6 deletions Avalonia.Gif/Decoding/LzwDecompressionException.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
// Licensed under the MIT License.
// Copyright (C) 2018 Jumar A. Macato, All Rights Reserved.

using System;
using System.Runtime.Serialization;

namespace Avalonia.Gif.Decoding
{
[Serializable]
Expand All @@ -16,8 +13,5 @@ public LzwDecompressionException(string message)

public LzwDecompressionException(string message, Exception innerException)
: base(message, innerException) { }

protected LzwDecompressionException(SerializationInfo info, StreamingContext context)
: base(info, context) { }
}
}
21 changes: 14 additions & 7 deletions Avalonia.Gif/GifInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,23 @@ public GifInstance(Stream currentStream)
CurrentCts = new CancellationTokenSource();

_gifDecoder = new GifDecoder(currentStream, CurrentCts.Token);
var pixSize = new PixelSize(_gifDecoder.Header.Dimensions.Width, _gifDecoder.Header.Dimensions.Height);

_targetBitmap = new WriteableBitmap(pixSize, new Vector(96, 96), PixelFormat.Bgra8888, AlphaFormat.Opaque);
var pixSize = new PixelSize(
_gifDecoder.Header.Dimensions.Width,
_gifDecoder.Header.Dimensions.Height
);

_targetBitmap = new WriteableBitmap(
pixSize,
new Vector(96, 96),
PixelFormat.Bgra8888,
AlphaFormat.Opaque
);
GifPixelSize = pixSize;

_totalTime = TimeSpan.Zero;

_frameTimes = _gifDecoder
.Frames
.Select(frame =>
.Frames.Select(frame =>
{
_totalTime = _totalTime.Add(frame.FrameDelay);
return _totalTime;
Expand Down Expand Up @@ -138,10 +145,10 @@ public void Dispose()

internal WriteableBitmap ProcessFrameIndex(int frameIndex)
{
_gifDecoder.RenderFrame(frameIndex, _targetBitmap);
_gifDecoder.RenderFrame(frameIndex, _targetBitmap!);
_currentFrameIndex = frameIndex;

return _targetBitmap;
return _targetBitmap!;
}
}
}
6 changes: 0 additions & 6 deletions Avalonia.Gif/InvalidGifStreamException.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
using System;
using System.Runtime.Serialization;

namespace Avalonia.Gif
{
[Serializable]
Expand All @@ -13,8 +10,5 @@ public InvalidGifStreamException(string message)

public InvalidGifStreamException(string message, Exception innerException)
: base(message, innerException) { }

protected InvalidGifStreamException(SerializationInfo info, StreamingContext context)
: base(info, context) { }
}
}
9 changes: 9 additions & 0 deletions Build/_utils.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

print_hyperlink() {
local url="$1"
local text="$2"

# macOS Terminal supports clickable links in the following format
printf "\033]8;;%s\a%s\033]8;;\a" "$url" "$text"
}
45 changes: 39 additions & 6 deletions Build/build_macos_app.sh
Original file line number Diff line number Diff line change
@@ -1,26 +1,59 @@
#!/bin/sh
#!/bin/bash

output_dir="$(pwd)/out/osx-arm64/"
app_name="Stability Matrix.app"

. "./_utils.sh" > /dev/null 2>&1 || . "${BASH_SOURCE%/*}/_utils.sh"

# Parse args
while getopts v: flag
do
case "${flag}" in
v) version=${OPTARG};;
*) echo "Invalid option";;
v)
version=${OPTARG}
;;
*)
echo "Invalid option: -$OPTARG" >&2
exit 2
;;
esac
done

shift $((OPTIND - 1))
echo $"Passing extra args to msbuild: $@"

set -e

# Build the app
dotnet \
msbuild \
StabilityMatrix.Avalonia \
-t:BundleApp \
-p:RuntimeIdentifier=osx-arm64 \
-p:UseAppHost=true \
-p:Configuration=Release \
-p:CFBundleShortVersionString="$version" \
-p:SelfContained=true \
-p:CFBundleName="Stability Matrix" \
-p:CFBundleDisplayName="Stability Matrix" \
-p:CFBundleVersion="$version" \
-p:PublishDir="$(pwd)/out/osx-arm64/bin" \
-p:CFBundleShortVersionString="$version" \
-p:PublishDir="${output_dir:?}/bin" \
"$@"

target_plist_path="${output_dir:?}/bin/${app_name:?}/Contents/Info.plist"

echo "> Checking Info.plist..."
file "${target_plist_path:?}"
plutil -lint "${target_plist_path:?}"

echo "> Copying app to output..."
# Delete existing file
rm -rf "${output_dir:?}/${app_name:?}"
# Copy the app out of bin
cp -r ./out/osx-arm64/bin/Stability\ Matrix.app ./out/osx-arm64/Stability\ Matrix.app
cp -r "${output_dir:?}/bin/${app_name:?}" "${output_dir:?}/${app_name:?}"

# Print output location
echo "[App Build Completed]"
print_hyperlink "file:///${output_dir:?}" "${output_dir:?}"
print_hyperlink "file:///${output_dir:?}/${app_name:?}" "${app_name:?}"
echo ""
94 changes: 94 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,100 @@ All notable changes to Stability Matrix will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning 2.0](https://semver.org/spec/v2.0.0.html).

## v2.12.0-pre.2
### Added
- Added "Show NSFW Images" toggle to the Checkpoints page
- Added "Model Loader" option to Inference, for loading UNet/GGUF/NF4 models (e.g. Flux)
- Added type-to-search for the Inference model selectors. Start typing while the dropdown is open to navigate the list.
- Added "Sign in with Google" option for connecting your Lykos Account on the Account Settings page
### Changed
- Updated Brazilian Portuguese translations thanks to thiagojramos
- Merged the "Flux Text to Image" workflow back into the main Text to Image workflow
### Fixed
- Fixed CivitAI Model Browser sometimes incorrectly showing "No models found" before toggling "Show NSFW" or "Hide Installed" filters
- Fixed Automatic1111 & related packages not including the gradio-allowed-path argument for the shared output folder
- Fixed SwarmUI settings being overwritten on launch
- Fixed Forge output folder links pointing to the incorrect folder
- LORAs are now sorted by model name properly in the Extra Networks dropdown
- Fixed errors when downloading models with invalid characters in the file name

## v2.12.0-pre.1
### Added
- Added "Hide Installed Models" toggle to the CivitAI Model Browser
### Changed
- ComfyUI will no longer be pinned to torch 2.1.2 for nvidia users on Windows
- Model browser download progress no longer covers the entire card for the entire duration of the download
- Updated torch index to `rocm6.0` for AMD users of ComfyUI
- (Internal) Updated to Avalonia 11.1.2
- OAuth-type connection errors in Account Settings now show a more detailed error message
### Fixed
- Fixed Inference not connecting with "Could not connect to backend - JSON value could not be converted" error with API changes from newer ComfyUI versions
- (macOS) Fixed OAuth connection prompts in Account Settings not automatically updating status after connection. Custom URL schemes are now also supported on macOS builds.

## v2.12.0-dev.3
### Added
- Added Settings option "Console: History Size" to adjust the number of lines stored in the console history when running packages. Defaults to 9001 lines.
#### Inference
- Added new project type, "Flux Text to Image", a Flux-native workflow for text-to-image projects
- Added support for the FP8 version of Flux in the regular Text to Image and Image to Image workflows via the "Use Flux Guidance" Sampler Addon
#### Model Browser
- Added AuraFlow & Flux base model types to the CivitAI model browser
- Added CLIP/Text Encoders section to HuggingFace model browser
#### Checkpoint Manager
- Added new Metadata Editor (accessible via the right-click menu), allowing you to create or edit metadata for models
- Added "New Directory" and "Delete" options to the context menu of the tree view.
- Added new toggle for drag & drop - when enabled, all selected models will now move together with the dragged model
- Added "File Size" sorting option
- Added "Hide Empty Categories" toggle
- Added "Select All" button to the InfoBar (shown when at least one model is selected)
- Added "unet" shared model folder for ComfyUI
### Changed
- Optimized image loading across the app, with loading speed now up to 4x faster for local images, and up to 17x faster for remote images
- Image loading in the Outputs page now uses native memory management for ~2x less peak memory usage, and will release memory more quickly when switching away from the Outputs page or scrolling images out of view
- Improved animation fluidity of image rendering while scrolling quickly across large collections (e.g. Outputs, Model Browser)
- The "Download Failed" message for model downloads is now persistent until dismissed
- Separated the Generate button from the prompt control in Inference so it can be moved like other controls
### Fixed
- Fixed "The version of the native libSkiaSharp library (88.1) is incompatible with this version of SkiaSharp." error for Linux users
- Fixed download links for IPAdapters in the HuggingFace model browser
- Fixed potential memory leak of transient controls (Inference Prompt and Output Image Viewer) not being garbage collected due to event subscriptions
- Fixed Batch Count seeds not being recorded properly in Inference projects and image metadata
### Supporters
#### Visionaries
- A heartfelt thank you to our Visionary-tier Patreon supporter, **Scopp Mcdee**! We truly appreciate your continued support!

## v2.12.0-dev.2
### Added
- Added Face Detailer module to Inference
- Added ultralytics models to HuggingFace model browser
- Added DoRA category to CivitAI model browser
- Added macOS support for Fooocus & related forks
- (Windows, Linux) Added Vulkan rendering support using launch argument `--vulkan`. (On Windows, the default WinUI composition renderer is likely still preferrable. Linux users are encouraged to try the new renderer to see if it improves performance and responsiveness.)
### Changed
- (Internal) Updated Avalonia to 11.1.1 - Includes major rendering and performance optimizations, animation refinements, improved IME / text selection, and improvements for window sizing / z-order / multi-monitor DPI scaling. ([avaloniaui.net/blog/avalonia-11-1-a-quantum-leap-in-cross-platform-ui-development](https://avaloniaui.net/blog/avalonia-11-1-a-quantum-leap-in-cross-platform-ui-development))
- (Internal) Updated SkiaSharp (Rendering Backend) to 3.0.0-preview.4.1, potentially fixes issues with window rendering artifacts on some machines.
- (Internal) Updated other dependencies for security and bug fixes.
### Fixed
- Fixed some ScrollViewers changing scroll position when focus changes
- Fixed [#782](https://github.com/LykosAI/StabilityMatrix/issues/782) - conflict error when launching new versions of Forge
- Fixed incorrect torch versions being installed for InvokeAI
### Supporters
#### Visionaries
- A huge thank you goes out to our esteemed Visionary-tier Patreon backers: **Scopp Mcdee**, **Waterclouds**, and **Akiro_Senkai**. Your kind support means the world!

## v2.12.0-dev.1
### Added
- Added new package: [Fooocus - mashb1t's 1-Up Edition](https://github.com/mashb1t/Fooocus) by mashb1t
- Added new package: [Stable Diffusion WebUI reForge](https://github.com/Panchovix/stable-diffusion-webui-reForge/) by Panchovix
- Image viewer context menus now have 2 options: `Copy (Ctrl+C)` which now always copies the image as a file, and `Copy as Bitmap (Shift+Ctrl+C)` (Available on Windows) which copies to the clipboard as native bitmap. This changes the previous single `Copy` button behavior that would first attempt a native bitmap copy on Windows when available, and fall back to a file copy if not.
- Added "Change Version" option to the package card overflow menu, allowing you to downgrade or upgrade a package to a specific version or commit
- Added "Disable Update Check" option to the package card overflow menu, allowing you to disable update checks for a specific package
- Added "Run Command" option in Settings for running a command with the embedded Python or Git executables
- Added Intel OneAPI XPU backend (IPEX) option for SD.Next
### Supporters
#### Visionaries
- Shoutout to our Visionary-tier Patreon supporters, **Scopp Mcdee**, **Waterclouds**, and our newest Visionary, **Akiro_Senkai**! Many thanks for your generous support!

## v2.11.8
### Added
- Added Flux & AuraFlow types to CivitAI Browser
Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<Project>
<PropertyGroup>
<AvaloniaVersion>11.0.9</AvaloniaVersion>
<AvaloniaVersion>11.1.3</AvaloniaVersion>
</PropertyGroup>
</Project>
Loading

0 comments on commit 43ea362

Please sign in to comment.