Skip to content

Commit

Permalink
Build: split sandboxed & TrollStore JIT version
Browse files Browse the repository at this point in the history
Sandboxed version installed using TrollStore will use URL Scheme to
enable JIT. tipa build keeps self-JIT but is unsafe to use.
  • Loading branch information
khanhduytran0 committed Jan 29, 2024
1 parent 7829917 commit a722b4a
Show file tree
Hide file tree
Showing 10 changed files with 82 additions and 20 deletions.
18 changes: 17 additions & 1 deletion .github/workflows/development.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,19 +116,35 @@ jobs:
export PATH=/opt/procursus/bin:/opt/homebrew/bin:$PATH
export RUNNER=1 SLIMMED=1
gmake -j$(sysctl -n hw.ncpu) dsym package PLATFORM=${{ matrix.platform }}
# Additionally build TrollStore (auto JIT) tipa for iOS
if [ "${{ matrix.platform_name }}" == "ios" ]; then
gmake -j$(sysctl -n hw.ncpu) dsym package PLATFORM=${{ matrix.platform }} TROLLSTORE_JIT_ENT=1
fi
- name: Upload regular ipa
uses: actions/upload-artifact@v3
with:
name: net.kdt.pojavlauncher-${{ matrix.platform_name }}.ipa
path: artifacts/net.kdt.pojavlauncher-*-${{ matrix.platform_name }}.ipa

- name: Upload regular tipa
uses: actions/upload-artifact@v3
with:
name: net.kdt.pojavlauncher-${{ matrix.platform_name }}-trollstore.tipa
path: artifacts/net.kdt.pojavlauncher-*-${{ matrix.platform_name }}-trollstore.tipa

- name: Upload slimmed ipa
uses: actions/upload-artifact@v3
with:
name: net.kdt.pojavlauncher.slimmed-${{ matrix.platform_name }}.ipa
path: artifacts/net.kdt.pojavlauncher.slimmed-*-${{ matrix.platform_name }}.ipa

- name: Upload slimmed tipa
uses: actions/upload-artifact@v3
with:
name: net.kdt.pojavlauncher.slimmed-${{ matrix.platform_name }}-trollstore.tipa
path: artifacts/net.kdt.pojavlauncher.slimmed-*-${{ matrix.platform_name }}-trollstore.tipa

- name: Upload PojavLauncher.dSYM
uses: actions/upload-artifact@v3
with:
Expand Down
12 changes: 11 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,23 @@ jobs:
export PATH=/opt/procursus/bin:/opt/homebrew/bin:$PATH
export RUNNER=1
gmake -j$(sysctl -n hw.ncpu) dsym package PLATFORM=${{ matrix.platform }}
# Additionally build TrollStore (auto JIT) tipa for iOS
if [ "${{ matrix.platform_name }}" == "ios" ]; then
gmake -j$(sysctl -n hw.ncpu) dsym package PLATFORM=${{ matrix.platform }} TROLLSTORE_JIT_ENT=1
fi
- name: Upload regular ipa
uses: actions/upload-artifact@v3
with:
name: net.kdt.pojavlauncher-${{ matrix.platform_name }}.ipa
path: artifacts/net.kdt.pojavlauncher-*-${{ matrix.platform_name }}.ipa

- name: Upload regular tipa
uses: actions/upload-artifact@v3
with:
name: net.kdt.pojavlauncher-${{ matrix.platform_name }}.tipa
path: artifacts/net.kdt.pojavlauncher-*-${{ matrix.platform_name }}-trollstore.tipa

- name: Upload PojavLauncher.dSYM
uses: actions/upload-artifact@v3
with:
Expand Down
1 change: 0 additions & 1 deletion JavaApp/src/main/java/net/kdt/pojavlaunch/uikit/UIKit.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ public static void updateMCGuiScale() {
System.load(System.getenv("BUNDLE_PATH") + "/PojavLauncher");
}

public static native void refreshAWTBuffer(int[] array);

// public static native void runOnUIThread(UIKitCallback callback);

Expand Down
18 changes: 13 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,16 @@ METHOD_CHANGE_PLAT = \

# Function to package the application
METHOD_PACKAGE = \
if [ '$(TROLLSTORE_JIT_ENT)' == '1' ]; then \
IPA_SUFFIX="-trollstore.tipa"; \
else \
IPA_SUFFIX=".ipa"; \
fi; \
if [ '$(SLIMMED_ONLY)' = '0' ]; then \
zip --symlinks -r $(OUTPUTDIR)/net.kdt.pojavlauncher-$(VERSION)-$(PLATFORM_NAME).ipa Payload; \
zip --symlinks -r $(OUTPUTDIR)/net.kdt.pojavlauncher-$(VERSION)-$(PLATFORM_NAME)$$IPA_SUFFIX Payload; \
fi; \
if [ '$(SLIMMED)' = '1' ] || [ '$(SLIMMED_ONLY)' = '1' ]; then \
zip --symlinks -r $(OUTPUTDIR)/net.kdt.pojavlauncher.slimmed-$(VERSION)-$(PLATFORM_NAME).ipa Payload --exclude='Payload/PojavLauncher.app/java_runtimes/*'; \
zip --symlinks -r $(OUTPUTDIR)/net.kdt.pojavlauncher.slimmed-$(VERSION)-$(PLATFORM_NAME)$$IPA_SUFFIX Payload --exclude='Payload/PojavLauncher.app/java_runtimes/*'; \
fi

# Function to download and unpack Java runtimes.
Expand Down Expand Up @@ -325,8 +330,11 @@ payload: native java jre assets
if [ '$(SLIMMED_ONLY)' != '1' ]; then \
cp -R $(OUTPUTDIR)/java_runtimes $(OUTPUTDIR)/Payload/PojavLauncher.app; \
fi
ldid -S $(OUTPUTDIR)/Payload/PojavLauncher.app; \
ldid -S$(SOURCEDIR)/entitlements.xml $(OUTPUTDIR)/Payload/PojavLauncher.app/PojavLauncher; \
if [ '$(TROLLSTORE_JIT_ENT)' == '1' ]; then \
ldid -S$(SOURCEDIR)/entitlements.trollstore.xml $(OUTPUTDIR)/Payload/PojavLauncher.app; \
else \
ldid -S$(SOURCEDIR)/entitlements.sideload.xml $(OUTPUTDIR)/Payload/PojavLauncher.app; \
fi
chmod -R 755 $(OUTPUTDIR)/Payload
if [ '$(PLATFORM)' != '2' ]; then \
$(call METHOD_MACHO,$(OUTPUTDIR)/Payload/PojavLauncher.app,$(call METHOD_CHANGE_PLAT,$(PLATFORM),$$file)); \
Expand All @@ -339,7 +347,7 @@ deploy:
cd $(OUTPUTDIR); \
if [ '$(IOS)' = '1' ]; then \
ldid -S $(WORKINGDIR)/PojavLauncher.app || exit 1; \
ldid -S$(SOURCEDIR)/entitlements.xml $(WORKINGDIR)/PojavLauncher.app/PojavLauncher || exit 1; \
ldid -S$(SOURCEDIR)/entitlements.trollstore.xml $(WORKINGDIR)/PojavLauncher.app/PojavLauncher || exit 1; \
sudo mv $(WORKINGDIR)/*.dylib $(PREFIX)Applications/PojavLauncher.app/Frameworks/ || exit 1; \
sudo mv $(WORKINGDIR)/PojavLauncher.app/PojavLauncher $(PREFIX)Applications/PojavLauncher.app/PojavLauncher || exit 1; \
sudo mv $(SOURCEDIR)/JavaApp/local_out/*.jar $(PREFIX)Applications/PojavLauncher.app/libs/ || exit 1; \
Expand Down
17 changes: 9 additions & 8 deletions Natives/JavaGUIViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -298,16 +298,17 @@ - (void)viewDidLoad {
setenv("POJAV_SKIP_JNI_GLFW", "1", 1);

// Register the display loop
CADisplayLink *displayLink = [CADisplayLink displayLinkWithTarget:surfaceView selector:@selector(refreshBuffer)];
if (@available(iOS 15.0, tvOS 15.0, *)) {
if(getPrefBool(@"video.max_framerate")) {
displayLink.preferredFrameRateRange = CAFrameRateRangeMake(30, 120, 120);
} else {
displayLink.preferredFrameRateRange = CAFrameRateRangeMake(30, 60, 60);
}
}
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
CADisplayLink *displayLink = [CADisplayLink displayLinkWithTarget:surfaceView selector:@selector(refreshBuffer)];
if (@available(iOS 15.0, tvOS 15.0, *)) {
if(getPrefBool(@"video.max_framerate")) {
displayLink.preferredFrameRateRange = CAFrameRateRangeMake(30, 120, 120);
} else {
displayLink.preferredFrameRateRange = CAFrameRateRangeMake(30, 60, 60);
}
}
[displayLink addToRunLoop:NSRunLoop.currentRunLoop forMode:NSRunLoopCommonModes];
[NSRunLoop.currentRunLoop run];
});


Expand Down
2 changes: 1 addition & 1 deletion Natives/LauncherMenuViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ - (void)viewDidLoad {
UIActivityViewController *activityVC;
if (realUIIdiom != UIUserInterfaceIdiomTV) {
activityVC = [[UIActivityViewController alloc]
initWithActivityItems:@[@"latestlog.txt", [NSURL URLWithString:latestlogPath]]
initWithActivityItems:@[[NSURL URLWithString:latestlogPath]]
applicationActivities:nil];
} else {
dlopen("/System/Library/PrivateFrameworks/SharingUI.framework/SharingUI", RTLD_GLOBAL);
Expand Down
8 changes: 6 additions & 2 deletions Natives/LauncherNavigationController.m
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,10 @@ - (void)invokeAfterJITEnabled:(void(^)(void))handler {
handler();
});
return;
} else if (getEntitlementValue(@"local.sandboxed-jit")) {
NSURL *jitURL = [NSURL URLWithString:[NSString stringWithFormat:@"apple-magnifier://enable-jit?bundle-id=%@", NSBundle.mainBundle.bundleIdentifier]];
[UIApplication.sharedApplication openURL:jitURL options:@{} completionHandler:nil];
// Do not return, wait for TrollStore to enable JIT and jump back
} else if (getPrefBool(@"debug.debug_skip_wait_jit")) {
NSLog(@"Debug option skipped waiting for JIT. Java might not work.");
handler();
Expand All @@ -302,8 +306,8 @@ - (void)invokeAfterJITEnabled:(void(^)(void))handler {

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
while (!isJITEnabled(false)) {
// Perform check for every second
sleep(1);
// Perform check for every 200ms
usleep(1000*200);
}
dispatch_async(dispatch_get_main_queue(), ^{
[alert dismissViewControllerAnimated:YES completion:handler];
Expand Down
2 changes: 1 addition & 1 deletion Natives/main.m
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ void init_logDeviceAndVer(char *argument) {

NSString *tsPath = [NSString stringWithFormat:@"%@/../_TrollStore", NSBundle.mainBundle.bundlePath];
const char *type;
if ([fm fileExistsAtPath:tsPath]) {
if (!access(tsPath.UTF8String, F_OK)) {
type = "TrollStore";
} else if (isJailbroken) {
type = "Jailbroken";
Expand Down
24 changes: 24 additions & 0 deletions entitlements.sideload.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>application-identifier</key>
<string>net.kdt.pojavlauncher</string>
<key>com.apple.private.security.container-required</key>
<string>net.kdt.pojavlauncher</string>
<key>get-task-allow</key>
<true/>

<key>com.apple.developer.kernel.extended-virtual-addressing</key>
<true/>
<key>com.apple.developer.kernel.increased-memory-limit</key>
<true/>

<!-- Give ability to change Jetsam task limit by itself -->
<key>com.apple.private.memorystatus</key>
<true/>

<!-- Custom entitlement to indicate this was installed with TrollStore, still sandboxed -->
<key>local.sandboxed-jit</key>
<true/>
</dict>
</plist>
File renamed without changes.

0 comments on commit a722b4a

Please sign in to comment.