Skip to content

Commit d598482

Browse files
authored
Revert "fixes #133: same task runner for platform&render" (#421)
1 parent 2f5654a commit d598482

File tree

5 files changed

+13
-44
lines changed

5 files changed

+13
-44
lines changed

application.go

-2
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,6 @@ func (a *Application) Run() error {
260260
fmt.Printf("go-flutter: engine.Run() returned result code %d (invalid library version)\n", result)
261261
case embedder.ResultInvalidArguments:
262262
fmt.Printf("go-flutter: engine.Run() returned result code %d (invalid arguments)\n", result)
263-
case embedder.ResultInternalInconsistency:
264-
fmt.Printf("go-flutter: engine.Run() returned result code %d (internal inconsistency)\n", result)
265263
default:
266264
fmt.Printf("go-flutter: engine.Run() returned result code %d (unknown result code)\n", result)
267265
}

embedder/embedder.go

-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ const (
3030
ResultSuccess Result = C.kSuccess
3131
ResultInvalidLibraryVersion Result = C.kInvalidLibraryVersion
3232
ResultInvalidArguments Result = C.kInvalidArguments
33-
ResultInternalInconsistency Result = C.kInternalInconsistency
3433
ResultEngineNotRunning Result = -1
3534
)
3635

embedder/embedder_helper.c

-2
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,7 @@ FlutterEngineResult runFlutter(void *user_data, FlutterEngine *engine, FlutterPr
5151

5252
FlutterCustomTaskRunners custom_task_runners = {};
5353
custom_task_runners.struct_size = sizeof(FlutterCustomTaskRunners);
54-
// Render task and platform task are handled by the same TaskRunner
5554
custom_task_runners.platform_task_runner = &platform_task_runner;
56-
custom_task_runners.render_task_runner = &platform_task_runner;
5755
Args->custom_task_runners = &custom_task_runners;
5856

5957
return FlutterEngineRun(FLUTTER_ENGINE_VERSION, &config, Args, user_data,

event-loop.go

+13-9
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,11 @@ import (
77
"time"
88

99
"github.com/go-flutter-desktop/go-flutter/embedder"
10-
"github.com/go-flutter-desktop/go-flutter/internal/currentthread"
1110
"github.com/go-flutter-desktop/go-flutter/internal/priorityqueue"
1211
)
1312

1413
// EventLoop is a event loop for the main thread that allows for delayed task
15-
// execution.
14+
// execution.()
1615
type EventLoop struct {
1716
// store the task (event) by their priorities
1817
priorityqueue *priorityqueue.PriorityQueue
@@ -23,19 +22,17 @@ type EventLoop struct {
2322

2423
// timeout for non-Rendering events that needs to be processed in a polling manner
2524
platformMessageRefreshRate time.Duration
26-
27-
// identifier for the current thread
28-
mainThreadID int64
2925
}
3026

27+
// newEventLoop must ALWAYS be called if the calling goroutine is
28+
// `runtime.LockOSThread()`
3129
func newEventLoop(postEmptyEvent func(), onExpiredTask func(*embedder.FlutterTask) embedder.Result) *EventLoop {
3230
pq := priorityqueue.NewPriorityQueue()
3331
heap.Init(pq)
3432
return &EventLoop{
3533
priorityqueue: pq,
3634
postEmptyEvent: postEmptyEvent,
3735
onExpiredTask: onExpiredTask,
38-
mainThreadID: currentthread.ID(),
3936

4037
// 25 Millisecond is arbitrary value, not too high (adds too much delay to
4138
// platform messages) and not too low (heavy CPU consumption).
@@ -49,10 +46,17 @@ func newEventLoop(postEmptyEvent func(), onExpiredTask func(*embedder.FlutterTas
4946
}
5047
}
5148

52-
// RunOnCurrentThread return true if tasks posted on the
53-
// calling thread will be run on that same thread.
49+
// RunOnCurrentThread FlutterDocs:
50+
// May be called from any thread. Should return true if tasks posted on the
51+
// calling thread will be run on that same thread.
52+
//
53+
// The functions PostTask and onExpiredTask should be called from the same
54+
// thread, this is ensured if the creation of the event loop (through
55+
// `newEventLoop`) and the PostTask callback (through
56+
// `a.engine.TaskRunnerPostTask = eventLoop.PostTask`) are done on a calling
57+
// goroutine which always execute in that thread (`runtime.LockOSThread()`).
5458
func (t *EventLoop) RunOnCurrentThread() bool {
55-
return currentthread.ID() == t.mainThreadID
59+
return true
5660
}
5761

5862
// PostTask posts a Flutter engine tasks to the event loop for delayed execution.

internal/currentthread/thread-id.go

-30
This file was deleted.

0 commit comments

Comments
 (0)