Remove supporting GopherJS

Fixes #1129
This commit is contained in:
Hajime Hoshi 2020-10-07 01:03:19 +09:00
parent 727cef96e3
commit 00f3d83d4c
7 changed files with 5 additions and 40 deletions

View File

@ -29,7 +29,6 @@ import (
"github.com/hajimehoshi/ebiten/v2/examples/resources/images"
"github.com/hajimehoshi/ebiten/v2/internal/graphics"
t "github.com/hajimehoshi/ebiten/v2/internal/testing"
"github.com/hajimehoshi/ebiten/v2/internal/web"
)
func skipTooSlowTests(t *testing.T) bool {
@ -37,10 +36,6 @@ func skipTooSlowTests(t *testing.T) bool {
t.Skip("skipping test in short mode")
return true
}
if web.IsGopherJS() {
t.Skip("too slow on GopherJS")
return true
}
if runtime.GOOS == "js" {
t.Skip("too slow or fragile on Wasm")
return true

View File

@ -61,7 +61,7 @@ type verticesBackend struct {
}
func (v *verticesBackend) slice(n int, last bool) []float32 {
// As this is called only from GopherJS, mutex is not required.
// As this is called only on browsers, mutex is not required.
need := n * VertexFloatNum
if l := len(v.backend); v.head+need > l {
@ -84,7 +84,7 @@ func (v *verticesBackend) slice(n int, last bool) []float32 {
func vertexSlice(n int, last bool) []float32 {
if web.IsBrowser() {
// In GopherJS and Wasm, allocating memory by make is expensive. Use the backend instead.
// In Wasm, allocating memory by make is expensive. Use the backend instead.
return theVerticesBackend.slice(n, last)
}
return make([]float32, n*VertexFloatNum)

View File

@ -15,5 +15,5 @@
// This can be compiled in non-JS environments to avoid a mysterious error: 'no Go source files'
// See https://travis-ci.org/hajimehoshi/ebiten/builds/603539948
// Package jsutil offers utility functions for GopherJS and Wasm.
// Package jsutil offers utility functions for Wasm.
package jsutil

View File

@ -17,8 +17,6 @@
package js
import (
"log"
"runtime"
"syscall/js"
"time"
@ -411,22 +409,7 @@ func (u *UserInterface) Run(context driver.UIContext) error {
canvas.Call("focus")
}
u.running = true
ch := u.loop(context)
if runtime.GOARCH == "wasm" {
return <-ch
}
// On GopherJS, the main goroutine cannot be blocked due to the bug (gopherjs/gopherjs#826).
// Return immediately.
go func() {
defer func() {
u.running = false
}()
if err := <-ch; err != nil {
log.Fatal(err)
}
}()
return nil
return <-u.loop(context)
}
func (u *UserInterface) RunWithoutMainLoop(context driver.UIContext) {

View File

@ -17,7 +17,6 @@
package web
import (
"runtime"
"strings"
"syscall/js"
)
@ -26,10 +25,6 @@ func IsBrowser() bool {
return true
}
func IsGopherJS() bool {
return IsBrowser() && runtime.GOOS != "js"
}
var (
userAgent = js.Global().Get("navigator").Get("userAgent").String()

View File

@ -20,10 +20,6 @@ func IsBrowser() bool {
return false
}
func IsGopherJS() bool {
return false
}
func IsIOSSafari() bool {
return false
}

6
run.go
View File

@ -153,13 +153,9 @@ func (i *imageDumperGameWithDraw) Layout(outsideWidth, outsideHeight int) (scree
// TPS (ticks per second) is 60 by default.
// This is not related to framerate (display's refresh rate).
//
// On non-GopherJS environments, RunGame returns error when 1) OpenGL error happens, 2) audio error happens or
// RunGame returns error when 1) OpenGL error happens, 2) audio error happens or
// 3) f returns error. In the case of 3), RunGame returns the same error.
//
// On GopherJS, RunGame returns immediately.
// It is because the 'main' goroutine cannot be blocked on GopherJS due to the bug (gopherjs/gopherjs#826).
// When an error happens, this is shown as an error on the console.
//
// The size unit is device-independent pixel.
//
// Don't call RunGame twice or more in one process.