Skip to content
This repository has been archived by the owner on Jan 26, 2025. It is now read-only.

Commit

Permalink
fix major hashlink crashes
Browse files Browse the repository at this point in the history
  • Loading branch information
MaybeMaru committed Dec 5, 2023
1 parent 4d2cf15 commit 76fef5e
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 11 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,31 @@ jobs:
name: Maru-Funkin-Linux
path: export/release/linux/bin
if-no-files-found: error

hashlinkBuild:
runs-on: windows-latest

steps:
- name: Checkout latest commit
uses: actions/checkout@main
with:
submodules: true

- name: Install & Setup Haxe
uses: krdlab/setup-haxe@master
with:
haxe-version: 4.3.3

- name: Install Libraries
run: |
haxe -cp ./actions -D analyzer-optimize -main Main --interp
- name: Build
run: haxelib run lime build hl

- name: Upload Artifact
uses: actions/upload-artifact@main
with:
name: Maru-Funkin-HashLink
path: export/release/hl/bin
if-no-files-found: error
3 changes: 3 additions & 0 deletions source/funkin/objects/note/Note.hx
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,10 @@ class Note extends FlxSpriteExt implements INoteData {
pixels.fillRect(new Rectangle(0, endPos, width, susEnd.height), FlxColor.fromRGB(0,0,0,0));
stampBitmap(susEnd, 0, endPos);

#if !hl
frames = AssetManager.uploadGpuFromKey(key).imageFrame; // After this the sustain bitmap data wont be readable, sorry
#end

origin.set(width * 0.5, 0);
}
}
Expand Down
2 changes: 1 addition & 1 deletion source/funkin/states/MusicBeatState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class MusicBeatState extends FlxUIState implements IMusicGetter {
override function destroy() {
instance = null;
super.destroy();
CoolUtil.runGc(false); // Minor Gc Clear
CoolUtil.gc(false);
}

// Some shortcuts
Expand Down
4 changes: 2 additions & 2 deletions source/funkin/states/editors/ChartingState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -643,8 +643,8 @@ class ChartingState extends MusicBeatState {
}, _);
}

function saveJson(input:Any, fileName:String) {
final data:String = cast input is String ? input : FunkyJson.stringify(input, "\t");
function saveJson(input:Dynamic, fileName:String) {
final data:String = input is String ? input : FunkyJson.stringify(input, "\t");
if (data.length > 0) {
final chartFile:FileReference = new FileReference();
chartFile.save(data.trim(), '$fileName.json');
Expand Down
23 changes: 15 additions & 8 deletions source/funkin/util/CoolUtil.hx
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
package funkin.util;

import funkin.util.backend.SongZip;
//import openfl.system.System;
#if cpp
import cpp.vm.Gc;
#elseif hl
import hl.Gc;
#elseif neko
import neko.vm.Gc;
#end
import funkin.util.backend.SongZip;
import openfl.system.System;

typedef CacheClearing = {
?bitmap:Bool,
Expand Down Expand Up @@ -77,14 +81,17 @@ class CoolUtil {
if (cacheClear.sustains) NoteUtil.clearSustainCache();
if (cacheClear.sounds) AssetManager.clearSoundCache(!softClear);
if (cacheClear.shaders) Shader.clearShaders();
runGc(true); // Major gc clear
gc(true);
}

inline public static function runGc(major:Bool = true) {
System.gc();
#if cpp
Gc.run(major);
if (major) Gc.compact();
inline public static function gc(major:Bool = false) {
#if hl
Gc.blocking(true);
Gc.major();
Gc.blocking(false);
#else
Gc.run(major);
#if cpp if (major) Gc.compact(); #end
#end
}

Expand Down

0 comments on commit 76fef5e

Please sign in to comment.