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

Thread still showing as running after termination #22

Open
Gama11 opened this issue Aug 26, 2019 · 2 comments
Open

Thread still showing as running after termination #22

Gama11 opened this issue Aug 26, 2019 · 2 comments
Labels
bug Something isn't working

Comments

@Gama11
Copy link
Member

Gama11 commented Aug 26, 2019

When running the following code (thanks for the code example @gepatto) and pressing Space to open a file dialog, a second thread appears in the callstack view:

package;

import lime.ui.FileDialogType;
import lime.ui.FileDialog;
import openfl.events.Event;
import openfl.net.URLRequest;
import openfl.display.Loader;
import openfl.display.Sprite;
import openfl.ui.Keyboard;
import openfl.events.KeyboardEvent;

class Main extends Sprite {
	var dialogOpen:Bool = false;
	var l:Loader;

	public function new() {
		super();
		stage.addEventListener(KeyboardEvent.KEY_DOWN, stage_keydown);
	}

	function loadComplete(e:Event) {}

	function stage_keydown(e:KeyboardEvent) {
		switch (e.keyCode) {
			case Keyboard.SPACE:
				selectImage();
			case Keyboard.DELETE:
				if (l != null) {
					l.unload();
					removeChild(l);
					l = null;
				}
		}
	};

	function selectImage() {
		#if !js
		if (dialogOpen)
			return; // prevent multiple dialogs
		if (l == null) {
			l = new Loader();
			l.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);
			addChild(l);
		} else {
			l.unload();
		}
		var dOpen = new FileDialog();
		dOpen.onSelect.add(function(path:String) {
			l.load(new URLRequest(path));
			dialogOpen = false;
		});
		dialogOpen = true;
		dOpen.browse(FileDialogType.OPEN);
		#end
	}
}

When the file dialog is closed, the thread should terminate, but the UI doesn't seem to update. I added some traces and found the following order of events:

threadStart {
	threadId : 0
}
threadStart {
	threadId : 2
}
threadExit {
	threadId : -1
}

So it looks like we don't get a valid thread ID on exit. Possibly a bug in hcxpp (@nulld)?

@Gama11
Copy link
Member Author

Gama11 commented Aug 26, 2019

HXCPP issue at HaxeFoundation/hxcpp#845.

@nulld
Copy link
Member

nulld commented Aug 26, 2019

Looks like we receive THREAD_TERMINATED event from cpp.vm.Debugger with threadNumber :-1.
So it's a bug or undocumented behaviour:
https://api.haxe.org/cpp/vm/Debugger.html#setEventNotificationHandler

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants