Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sys.Thread.create doesn't work on android target #12

Closed
sannyun opened this issue Mar 3, 2021 · 1 comment
Closed

sys.Thread.create doesn't work on android target #12

sannyun opened this issue Mar 3, 2021 · 1 comment

Comments

@sannyun
Copy link

sannyun commented Mar 3, 2021

sys.Thread.create call freezes calling thread at

info->mSemaphore->Wait();

It looks like hxThreadFunc that is passed as HxCreateDetachedThread's param may not be called.
I noticed that khacpp's HxCreateDetachedThread definishion stores pointer to hxThreadFunc in local variable kinc_thread_t thread. And then pointer to it is passed to pthread_create. Could it be related?

This can be reproduced with minimal Kha project (make --init) and Thread.create placed somewhere in main, compiled for android (make android-native...)

        ...
	public static function main() {
		System.start({title: "Project", width: 1024, height: 768}, function (_) {
			// Just loading everything is ok for small projects
			Assets.loadEverything(function () {
				// Avoid passing update/render directly,
				// so replacing them via code injection works
				Scheduler.addTimeTask(function () { update(); }, 0, 1 / 60);
				System.notifyOnFrames(function (frames) { render(frames); });

				Thread .create(threadBody);
			});
		});
	}

	private static function threadBody(): Void {
		
		while (true) {
			Sys.sleep(1.0);
		}
	}
@tcdude
Copy link
Contributor

tcdude commented Mar 5, 2021

This used to work for me, before I updated my local Kha repo. Is it possible that it broke when you removed the last Kore things and replaced with Kinc things?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants