iTranslated by AI

The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
🐄

2021 Year in Review

に公開

General Overview

I feel like it was a year with a lot of learning. It was important not to stay confined within my own specialties, or something like that.

In my main job, the compensation became exceptionally generous for a domestic office—specifically, the bonus alone reached the level of my annual salary in my second year at the company—which would have been unbelievable a while ago. Since there are no major company events for a while, I expect it will likely drop to 1/2 to 3/4. In terms of position, I became what is called a "Lead" (Shunin) in Japanese, but since I don't have any subordinates, it doesn't feel like much...

Regarding activities outside my main job, I made quite some progress on things I can publish and focus on (Yuniframe). As for the non-public ones (game development, etc.), it's been a mix of progress and setbacks, and I feel the need to rethink my approach a bit.

This Year's Hit Award

I couldn't allocate much time to writing articles this year. Still, reaching 385 B! (Hatena Bookmarks) was a personal record.

https://b.hatena.ne.jp/entry/s/zenn.dev/okuoku/articles/e12f39e5c669cc

https://b.hatena.ne.jp/entry/s/zenn.dev/okuoku/articles/bc57255d35dfad

Regarding the "Apple's ~" article, there was a draft to write it more darkly, focusing on hacking and business models, but I leaned towards a more refreshing tone. It's a technique to get clicks. Personally, I've felt for the past few years that Apple's immediate goal is to attach cameras or radar to humans, and I feel the article might have had a bigger impact if I had written it about security as a path toward that. Well, everyone perceives that differently and it's unpredictable, so I kept that aspect quite compact in the article.

There might be a critique like "Your own project's articles aren't in there," but I believe that things that gather three-digit bookmarks should be done by others in the first place, so you could say that's according to plan. Even good ideas only receive small recognition at first, and I don't think the scale of the audience is proportional to the quality of the idea. Great ideas are accepted by the masses from the start, but such things should probably be turned into businesses anyway.

Project Progress

I invested quite a bit of time and financial resources into Yuniframe. In fact, all my public activities can be said to be part of the Yuniframe project.

Running WebAssembly Games on My Own Platform (Yuniframe)

Currently, Unity is running with Duktape + wasm2c + C-WebGL.

https://zenn.dev/okuoku/articles/5a7a04e75234b3

https://zenn.dev/okuoku/articles/9276f1bc71fc70

Considering that at the beginning of 2021, I was running both WebAssembly and JavaScript on Node.js, I think this is reasonable progress. For legal reasons, I haven't released the final packager.

In my first attempt, I used JSDom and dealt with the DOM quite seriously, but I realized that for code on the scale of Unity, the DOM can be handled loosely, and it's working out even with an actually incredibly simple wrapper.

A similar case where a Go app was ported to Nintendo Switch appeared using almost the same method, but they seem to have abandoned this approach through optimizations on the Go side.

https://zenn.dev/hajimehoshi/articles/72f027db464280

The "slow compilation" and "lack of multi-threading" mentioned in that article will likely be issues for Yuniframe as well. The former can be managed with some ingenuity, but the latter seems difficult to solve in the short term because the structure of Unity WebGL is quite unrefined in the first place.

Yuniframe

The explanation of what Yuniframe actually is hasn't quite reached a final definition, but currently, I summarize it as:

  • A system for writing extremely portable games in C.

Why is it portable? Because Yuniframe's design eliminates all system calls and allows interaction with the OS/platform through nothing but NCCC, a single calling convention void func(const uint64_t* in, uint64_t* out) [1] . Function calls can be made in any environment that has a C compiler, and since no OS/platform-specific structures exist, there are no header compatibility issues. ...In reality, even Windows and Linux have incompatible calling conventions, making it difficult to leverage this trait, but in environments like WebAssembly where a single calling convention is used universally, it becomes a powerful feature.

Some might say that this is just replacing structures and function signatures with uint64_t arrays, but I feel there's a method for application construction that emerges by pushing minimalism to the extreme. UNIX philosophy.

In fact, the world of Web APIs seems to have evolved exponentially by making everything .json. Even though ASN.1 and XML had existed since ancient times, .json was necessary for that evolution. In other words, .json parsers are everywhere, while ASN.1 and XML were just a little bit more troublesome to handle, which might have hindered evolution. Similarly, the philosophy of Yuniframe is to literally zero out the cost required for an application to be ported between OSes. For example, while POSIX is relatively portable, the effort for porting between OSes is never zero.

(I am intentionally ignoring the existence of big-endian CPUs, just like WebAssembly does.)

Of course, just as HTTP became a binary protocol from version 2 onwards, and the adoption of Protocol Buffers is increasing in various fields, there is always a swing back toward complex and cumbersome binaries. However, there are few past examples of success through such simplification in this field, and the reality is that WASI, a similar project for WebAssembly, is leaning toward the complex side (for security reasons).

So, Yuniframe has achieved a feature set (built on top of SDL2) through sheer grit that allows for porting WebGL games as mentioned above. The structure of web apps—that is, allowing a game to be created with just the functionality of drawing a single game screen—is a very good match for cases like Yuniframe where one wants to implement only the bare minimum functionality. The key point of Yuniframe is perhaps the (re)discovery of repurposing this web app structure for building native apps, in a way that differs from React Native.

C-WebGL

C-WebGL, a C language version of WebGL 1, has been implemented to the point where it can render using a Vulkan backend.

https://twitter.com/okuoku/status/1427234852483440642

Currently, C-WebGL is included in the Yuniframe prototype repository, but I am considering spinning it out at some point. The implementation is being carried out in four stages:

  1. gles2: A pass-through implementation to the system's OpenGL ES.
  2. tracker: An implementation that only tracks all the states that OpenGL ES 2 can handle.
  3. tgles2: An implementation that uses the tracker to render by matching the system's OpenGL ES to the tracked settings at the time of a draw call.
  4. vulkan: An implementation that performs rendering with Vulkan using the tracker.

The key point is that Unity WebGL works at any of these stages. This allowed me to proceed with implementation under very favorable conditions for a GPU library, where complex use cases exist that cannot be covered by simple tests.

For example, if there is something I don't understand about the Vulkan specification, I can obtain an "exemplar" by running the gles2 implementation with Vulkan (using ANGLE) and comparing them.

The structure of modern GPU APIs is basically stateless. In OpenGL, parameters such as line width are expressed as states on the system, but the tracker module allows these to be recorded independently from the GPU, which is a design intended to reduce the implementation burden on the GPU backend. (Mesa and ANGLE adopt similar implementation policies.)

I haven't made much progress lately as I've been using my development machine for other things, but I would like to complete the DX11 backend. (This would be useful for Xbox—the current Xbox implementation uses ANGLE, so it's huge and difficult to manage.)

Since the current C-WebGL only implements the parts necessary for Unity WebGL, it is much more compact than ANGLE, which is typically used to implement WebGL in browsers. ANGLE is a very large library because it implements almost all of OpenGL ES 3.2.

In the future, I will have to think about WebGL 2 because Safari has started supporting it, but progress is slow. On the other hand, I am also considering whether WebGL can be executed using the OpenGL 1 fixed-function pipeline. In reality, most of the programmable pipeline is not used just for web browsing, so it might be possible to power down the GPU quite aggressively. I predict there will be a need for a way to round down compositions currently written in OpenGL 2 into a form that is easier to execute securely on the CPU.

Mini-XR, C-Fetch, ...

In addition, I have researched the standardization status of various Web platform APIs and explored whether they could be turned into C language APIs. I wrote some of this in scraps, but currently, I haven't been able to turn any of it into articles.

The Web platform is an excellent resource because the work of researching the differences between various companies' OSes/platforms and extracting the common parts has already been done beforehand. Since most of the SDK design work is spent on this part, being able to outsource it is a significant advantage.

However, while the research is progressing, I'm at a loss because I can't use the method of verifying by running existing apps as I did with C-WebGL.

Next Year

I hope next year will be the year when long-shot plans start to land...

Can I make a battery-powered smartphone toy? (Yuniframe for microcontrollers)

https://zenn.dev/okuoku/scraps/815d555243b6a4

Occasionally, I feel that I must work on a "project that I think is cool for no particular reason" to maintain my strength as an architect, and I have chosen this as my theme.

(Partly because at my main job, with the depth of talent typical of a large corporation, I haven't reached the level of skill where I can act as an architect—others end up doing it anyway.)

For high-end children's toys, the specs reach Resistive touch panel + Color LCD + Camera capable of reading QR codes = 9,680 yen, so I'd like to think for myself what kind of specs and architecture a "smartphone toy" would have if built with this level of form factor.

... However, microcontrollers that can connect to a camera are actually very rare and highly difficult. Currently, I am experimenting with the basic parts using Maix Amigo, but this has quite unrealistic specs with a RISC-V 64-bit dual-core + 8MiB RAM, and I'd like to use something with slightly lower specs like the Sony Spresense or ESP32. Well, although the North American Tamagotchi Pix has 8MiB of RAM...

Currently, I am refining the specs by walking around with sensors attached.

https://twitter.com/okuoku/status/1469987324004298756

Although smartphones are familiar, there is a tendency not to notice the uniqueness of their architecture (e.g., they keep running in the background even when the screen is off, they need to composite the application screen and the OS screen for display, etc.). I think it would be interesting to fit that into a few MiB of RAM with those considerations in mind. For apps that require a connection like web browsers, the cloud is fine anyway.

脚注
  1. In reality, it violates the strict aliasing rule, so I plan to change it to a union ↩︎

Discussion